Raku / old-design-docs

Raku language design documents
https://design.raku.org/
Artistic License 2.0
124 stars 36 forks source link

declare eval() and .eval() to be macro-like, make all-caps #50

Closed pmichaud closed 10 years ago

pmichaud commented 11 years ago

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

cedric-vincent commented 11 years ago

+1 for EVAL in all-caps, since it is really SPECIAL ;)

ghost commented 11 years ago

+1 for yelling, and maybe it could be dehuffmanised a bit: "EVALUATE". Or is that going too far?

perlpilot commented 11 years ago

+1 for shouting

jnthn commented 11 years ago

I'm not so fond of the uppercasing, but certainly of the macro-ish definition, so we can analyze stuff much better.

pmichaud commented 11 years ago

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

grondilu commented 11 years ago

Shouting for this seems a bit weird. Why not keep the current non-macroish version in lowercase and add an uppercase macro-ish version?

leto commented 11 years ago

+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

pmichaud commented 11 years ago

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

diakopter commented 11 years ago

EVAL(+1) also..

diakopter commented 11 years ago

<< bump >>

mathw commented 11 years ago

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.

supernovus commented 11 years ago

+1 to EVAL