Open
Description
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