Do you know where your variables are? | |
PerlMonks |
RFC: Concise OOP Syntaxby LanX (Saint) |
on Aug 05, 2019 at 00:59 UTC ( [id://11103898]=perlmeditation: print w/replies, xml ) | Need Help?? |
Dear monastery! In continuation to I tried to hack a proof of concept for a concise OO syntaxThe basic ideas are that:
Declaration of instance variable
Access of instance variables inside methods
$self
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:
<Reveal this spoiler or all in this thread> 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. Comments?
Cheers Rolf
Back to
Meditations
|
|