Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rudi opened this issue Nov 29, 2022 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@rudi
Copy link
Collaborator

rudi commented Nov 29, 2022

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
@rudi rudi added the enhancement New feature or request label Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant