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

classes, fields, constructors, and methods #249

Closed
wants to merge 35 commits into from
Closed

Conversation

mflatt
Copy link
Member

@mflatt mflatt commented Oct 29, 2022

Evolving design document is at https://github.com/mflatt/rhombus-prototype/blob/class/design/class/class.md

This is still very much a work in progress, and methods aren't in place, yet. But this overall approach to the syntax seems to be working, and field declaration and constructor-customization part is maybe all there.

design/class/class.md Outdated Show resolved Hide resolved
Adds `method`, `override`, a method mode for `final`, and `this`.
As a first cut, all methods must have distinct names or the same
implementation (i.e., implementation in the same interface or
unimplemented).
Private implementation of an interface is intended for implementing
interfaces like `Equals` or `Print` without exposing the implementing
methods publically.
@mflatt
Copy link
Member Author

mflatt commented Nov 8, 2022

Now with methods and interfaces — and worth a closer look from anyone who is interested.

Probably most of the details will seem obvious, although specific syntactic choices are always debatable. The least obvious parts of the design (still with some precedents) are (1) the handling of constructor, binding, and annotation customization with subclassing, and (2) the notion of implementing an interface privately.

Remaining work includes defining interfaces for equality and printing, sorting out method access via a class name (as opposed to an object annotated with the class), exposing the meta-time API for defining class and interface clauses, and writing overview documentation and examples in the reference.

Allow a subclass of a class with a custom constructor to use a default
constructor. The default assumes that the superclass constructor
accepts arguments consistent with its `field_spec`s.

Add support for `private` in a `field_spec`, so that it's possible to
add new immutable fields plus a custom constructor without foorcing
changes in subclasses.

Get rid of the wacky syntactic currying and non-hygienic `super`
binding for custom bindings and annotations. Instead, customizations
can use the name bound by `internal` plus a `&&` binding or annotation
operator.

Fix the `internal` name as a constructor to be consistent with a
custom constructor in the superclass. In particular, it has the same
calling convention as `super` within a constructor --- but `super` is
still needed, because that potentially instantiates a subclass, while
the internal name always instanties the class its associated with.

Fix `internal` names to consistently provide access to private fields
and methods.
They don't do anything, yet, but the syntax is checked.

A `method` declaration within an `interface` is treated as `abstract
method` if the method does not have a body block.
Also, start on overview section for subclasses, interfaces, abd
methods.
Also, associate static information from the result annotation to
method calls.
Includes a repair for static information on `super` in a constructor.
@mflatt
Copy link
Member Author

mflatt commented Nov 19, 2022

Merged as c917717

@mflatt mflatt closed this Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants