3 ms·
The only thing blocks have to do with this, is that Perl6 has to internally track state so that closed over values go out of scope when their parent block ends.
by shakna 10y ago
The only thing blocks have to do with this, is that Perl6 has to internally track state so that closed over values go out of scope when their parent block ends. End of story.
Maybe I can try explaining again.
Eval is unsafe as it reads input values in terms of the current state of a program.
It's environment is implicitly given, and includes the entirety of the Perl6 language, as well as anything user-created.
But, what if the programmer was allowed to supply that context?
Rather than a blacklist against certain bad things, this is a whitelist where you supply every single thing that eval is allowed to use.
Other languages already have this.
Scheme example that works:
(eval '(+ 1 2) (let (null-environment) '(+ . +)))
Scheme eval that fails:
(eval '(+ 1 2) (null-environment))
Perl6's flexibility is less unsafe when you don't provide anything flexible.