perlang-org / perlang

The Perlang Programming Language (GitHub Mirror)
https://gitlab.perlang.org/perlang/perlang
MIT License
16 stars 1 forks source link

Add class support #66

Closed perlun closed 3 months ago

perlun commented 4 years ago

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 from jlox 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)

Features likely to get implemented, but not as of the initial effort (0.2.0 or "Later")

Features that are likely to not ever get implemented (i.e. "non-goals")

Implementation details

Implemented parts (included in 0.1.0)

Remaining parts

perlun commented 2 years 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.