|go ahead... be a heretic|
RFC: Concise OOP Syntaxby LanX (Sage)
|on Aug 05, 2019 at 00:59 UTC||Need Help??|
In continuation to
The basic ideas are that:
Declaration of instance variable
Access of instance variables inside methods
The implementation is done via a macro expansion from use Class which injects some boilerplate into the head of the class, which handles the creation.
Injecting is basically done via a source filter or alternatively via Keyword::Simple. NB: just injecting some code doing introspection. No parsing, regexing or modification of the code you see.
I'm supposing this concise syntax could be used as a front end for all current OO models in Perl and might help offering a stable backwards compatible syntax if it's hardcoded into the engine.
A rough proof of concept follows here:
NB: This example is pretty barebone, and not meant to be an alternative to other OO Frameworks, but rather a frontend. It doesn't create accessors and the constructor is only simplistic.