I'm writing a module for creating enums with custom behaviour. What I do at the moment is add the enum to the GLOBAL
package, but that doesn't install any lexical symbols unless you create the enum in one module and import it from another. Using BEGIN $*W.install_lexical_symbol(...)
is not an option since the values for the enum could be obtained from, say, a network connection, and would block compilation until the values are received. Is it possible to install the lexical symbol in the caller's context at runtime? If so, how?
I'm going to say flat out "No".
(I usually learn to regret doing that with P6 but what the hey.)
My primary evidence is comments like "the set of symbols in a lexical scope is immutable after compile time".
Maybe grab a sick bag and go read the suggestions at How to define variable names dynamically in Perl 6? that are both evil and still not evil enough to do what I think you're asking for.
When you've finished throwing up, please seal the bag and then visit the freenode IRC channel #perl6-dev where the true experts in things related to guts hang out. (I think you know about that but thought I'd include it in this answer for posterity and because I seem to have a sick sense of humor.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With