elan-language / LanguageAndIDE

Apache License 2.0
3 stars 0 forks source link

Permit abstract classes to define private concrete methods #606

Open richardpawson opened 2 months ago

richardpawson commented 2 months ago

In Elan, private has the same meaning as protected in C#/Java - visible to sub-classes but not externally.

So we may have:

abstract class Foo ... private procedure defaultBar() ...

abstract procedure Bar() ... end class

class Yon inherits Foo

procedure Bar() . call defaultBar() end procedure end class

(where default is a convention only, not a recognised prefix).

If a class inherits from two abstract classes that ...

While the latter would not be acceptable in a commercial language for large-scale systems, this is unlikely to be an issue in an educational context, any more than not supporting overloaded methods generally.

richardpawson commented 2 weeks ago

Assigned to RP to permit private methods to be added to an abstract class in the MemberSelector

richardpawson commented 1 week ago

The parser now permits creating private property, procedure, and function - directly from the MemberSelector (i.e. no optional private keyword in the frame any more).

These private members can be added into a regular class, an immutable class (except for procedure), and also as concrete members in both abstract class', and abstract immutable class`.

Passing over to Stef to implement the private members in compiled code.

Note, however, that private property, private procedure, and private function have been temporarily removed from the "class_members" property of the default profile.json - pending their implementation.

scascarini commented 2 hours ago

For discussion

  1. Can a private member on an abstract class access inherited private members? Currently because of multiple inheritance we have a 'mixin' implementation. So this could be done but will add another layer of complexity.
  2. Currently a private member on an abstract class cannot call abstract members on the same class. I can't at the moment see how this can be implemented.