I have never really looked at the Perl-internals, but I can vagly remember having seen an implementation of Scheme in Scheme.
If I remember correctly there was a data-structure containing all the variable-bindings for any lexical scope and every closure would simply keep a reference to this.
So in this approach there is not a "capturing of all lexicals" but simply remembering one data-structure regardless of how many variables were defined it.
Perl evidently does this differently and I even think that the inaccessabilty of certain lexial variables of which Perl could not see that the are going to be used in a closure is a weakness.
I will try this in Rakudo.
In reply to Re^6: Accessing lexicals in other scopes dynamically by name
by morgon
in thread Accessing lexicals in other scopes dynamically by name
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |