in reply to Re: [DSL] disabling packages in Perl? (updated)
in thread [DSL] disabling packages in Perl?
> 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
sub SQL(&) :prepend('package mySQL; use DSL::mySQL;') { ... }
and whenever I execute
SQL { SELECT {} FROM {} WHERE {} }
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.
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
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
¹) well this should better be in the meditation section ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: [DSL] disabling packages in Perl? (meditation)
by haukex (Archbishop) on Apr 23, 2016 at 20:28 UTC |