declare eval() and .eval() to be macro-like, make all-caps
pmichaud opened this issue · 12 comments
At the YAPC::NA 2013 hackathon, there was discussion of making Cool.eval
and eval(...)
act more like macros, so they can be detected at compile time and pessimized appropriately.
It was also suggested that they become all-caps ( EVAL
and .EVAL
), since like MONKEY_TYPING they represent operations that are "special" and perhaps denote extra attention from programmers due to their side effects (some perhaps unwanted, such as security vulnerabilities).
Pm
+1 for EVAL in all-caps, since it is really SPECIAL ;)
+1 for yelling, and maybe it could be dehuffmanised a bit: "EVALUATE". Or is that going too far?
+1 for shouting
I'm not so fond of the uppercasing, but certainly of the macro-ish definition, so we can analyze stuff much better.
Another related possibility is to require that any outer-scoped variables that are to be accessible from an eval (or feed?) have to be explicitly declared with an is eval
trait or something like that.
my $a is eval;
my $b;
eval('say $a + 1'); # ok
eval('say $b + 1'); # not ok, $b not declared available
Pm
Shouting for this seems a bit weird. Why not keep the current
non-macroish version in lowercase and add an uppercase macro-ish
version?
+1 to making it clear to developers that "eval" is special and care should be taken when using it.
Also, I suggest looking at Eval::Clean and emulating the feature set that it has:
https://github.com/rafl/eval-clean
/cc @rafl
On Fri, Jun 07, 2013 at 03:56:43PM -0700, grondilu wrote:
Shouting for this seems a bit weird. Why not keep the current
non-macroish version in lowercase and add an uppercase macro-ish
version?
...but the whole point is to eliminate the non-macroish version of eval.
A purely runtime eval significantly restricts the types of compile-time
optimizations that can be performed.
I simply added that in the process of making eval() macro-like, it
might also be worthwhile to make it all-caps.
Pm
EVAL(+1) also..
<< bump >>
eval is very special, so having it in all-caps would be consistent with some other special things. Heck, even the metaclass stuff is in uppercase - .WHAT, .HOW etc. EVAL definitely fits for me into the 'strange stuff happening here' category of operations, alongside BEGIN, INIT, CATCH and so forth.
+1 to EVAL