68 points · by jsnell · 9y ago · 38 comments
my &eval = &EVAL
then that is largely moot.If we have a try block, and call a function, and if that function throws, we want the try block to be able to catch that. The function is not understood as having magic access to an environment; it's a pervasive dynamic environment that is visible to the current execution context at all times, in which exit points for non-local transfers are established.
That's almost the entire point since an error situation that is entirely confined to a lexical scope can be dealt with using some local control flow (some form of goto, or structured derivative thereof).
Their main objection to the pragma would seem to be the MONKEY-SEE-NO-EVAL name; if you don't understand the reference, say you're a non-native speaker, or just have no idea what it's referring to, all you'll see is "NO-EVAL", and then get confused why the code suddenly allows EVAL everywhere. Levity and fun is perfectly acceptable, but is it just as acceptable when the language is less obvious for it's extended developer community?
Why jump up and down screaming eval is super bad, when instead you could have allowed users to specify the context of eval, and made it safe to use?
Suppose for a moment that the scope of eval was truly an environment:
And you don't supply the resulting environment with anything but the functions you want.
Not even the dot operator, let alone magic builtins.
Python's eval suddenly becomes much safer. Unfortunately such an eval is harder to implement in Python, because every object carries it's magic methods with it, rather than looking them up elsewhere.
I agree with the author that this is probably overkill, in terms of warning about eval, but I'm also not understanding how merely having a block with a block scoped environment can make eval safe.
Having blocks simply means half the work of implementing eval this way has already been done in the interpreter.
Eval wouldn't have access to the base language if handed an empty environment.