Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around lexical import limits hit by T::P::Widget
Use jnthn++'s suggestion* and vector cross-package reference to the T singleton through PROCESS::<$TERMINAL>. * https://irclog.perlgeek.de/perl6-dev/2016-12-20#i_13775229
- Loading branch information
Geoffrey Broadwell
committed
Dec 20, 2016
1 parent
b4f4abc
commit 5b2452f
Showing
2 changed files
with
3 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5b2452f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a really useful demonstration of the use of dynamic variables!
5b2452f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So how does this work?
Does PROCESS::<$TERMINAL> become $*TERMINAL?
I've been having issues understanding how Dynamic Variables are created.
5b2452f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Xliff: Essentially, in any scope you can declare
my $*foo;
and then any other routine (or chain of routines) you call from that scope will be able to see$*foo
as well. So if you define:it will Just Work. The way that this plays out in practice is that when a dynamic variable is declared, it is installed in the local lexical scope; when it is referenced, the runtime will do a search through the call stack (starting at the local scope) searching for that dynamic variable. If it can't find it in any lexical scope, it then strips the
*
twigil and searches next in the interpreter globals (GLOBAL::
) and then finally the process globals (PROCESS::
). Failing that, it will give up and error.5b2452f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.