Closed perlun closed 2 months ago
Unclear about how/if this will get implemented. I'll mark it as "Later" for now and we'll give it some thought/time; there are other more important things (like arrays/index operator, perhaps struct
for dealing with binary file formats etc) which are blocking us more at the moment. It's still possible to design (smaller) programs without proper class
and/or OOP support.
Moved to GitLab
Please continue to the new version of this issue here: https://gitlab.perlang.org/perlang/perlang/-/issues/66. The GitHub page you are currently reading will not contain the latest information on this issue.
This is not going to be trivial, partially since our current
TypeReference
implementation presumes that variables and functions always return a valid CLR type. Well, a class being defined in the global (or local) scope, isn't a CLR type (at least not until we make the move to make all Perlang classes exist as valid CLR types as well - this move will come at some point to make Perlang code interop with existing .NET code properly, being able to implement .NET interfaces by Perlang classes etc), so that's at least one of the challenges. There will probably be numerous others as well.Here's the Crafting Interpreters chapter about the
jlox
implementation of classes: https://craftinginterpreters.com/classes.html. It doesn't help us that much since the static typing support we added in #54 has made things much more complex. We are already quite different fromjlox
and there is unfortunately no-one apart from ourselves that we can ask for help about how things work in our code base...Initial features (supported in 0.1.0)
static
C# methods to support things likeBase64.encode
andBase64.decode
(initially exposed asbase64_encode
andbase64_decode
but moved to class-based static methods in #79)Features likely to get implemented, but not as of the initial effort (0.2.0 or "Later")
IntList
(mutableList<int>
, for lack of generics)new
keyword for this or similar, unless we go the Ruby approach and just tack.new()
after the class name. Making constructors be nothing else than plain static factory methods does have a few advantages, but it makes things likefinal
fields (which must be initialized statically or in the constructor) way harder to achieve.public
,private
,protected
,internal
,protected internal
(similar to package-private in Java, which unfortunately can only be specified by not explicitly giving a visibility. This is one of the design deficiencies of the Java language from my perspective)Features that are likely to not ever get implemented (i.e. "non-goals")
Implementation details
Implemented parts (included in 0.1.0)
Remaining parts