good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^2: [DSL] disabling packages in Perl? (meditation)by LanX (Saint) |
on Apr 19, 2016 at 12:55 UTC ( [id://1160885]=note: print w/replies, xml ) | Need Help?? |
Thanks a lot ... unfortunately I'm too busy like now to test it all out or elaborate much further. > I imagine that packages named IN and LIKE are unlikely to clash with other packages... That's true but I'm looking for a general "solution" ... > Also, by "disabling", do you mean actually undefining the methods, or just setting a flag such that they fail when called outside of the appropriate scope (whichever one that is)? hmm good question... Ideally I'd like to be able to attach a "domain" to a code block to automatically have package and uses prepended, something like
and whenever I execute
then the code block is already parsed with methods imported from DSL::SQL which are not visible outside of the code block. OTOH variables from the outer scope would be visible inside the inner scope.
some background¹ ...I'm meditating about internal DSLs ("Domain Specific Languages") and ideally a "sub language" could be included adding new "syntax" (or better phrased syntactic sugar) not leaking to the outer scope. Traditionally we often use outer DSLs defined in strings/files which need to be parsed and evaluated. Take for instance a template system like TT. CGI.pm used to have an inner DSL to build HTML, there is also Jade for HTML in JS or LINQ for SQL in .NET .
Cheers Rolf
¹) well this should better be in the meditation section ...
In Section
Seekers of Perl Wisdom
|
|