Skip to content

Introduce constructor and regularize construction of objects in a hierarchy #14

Open
@rudi

Description

@rudi

Current status

To instantiate an object of a class that inherits from another class, the new expression takes all parameters from the superclass(es) and the class, in the sequence given by the inheritance hierarchy.

Proposal

Introduce an init block that calls super to initialize the fields of the direct superclass.

Example

Old version

class A(int x)
end

class B(int y)
end

main
   B x = new B(0, 0)
end

Proposed syntax

class A(int x)
end

class B(int y)
   init
      super(y)
   end
end

main
   B x = new B(0);
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions