broquaint has asked for the wisdom of the Perl Monks concerning the following question:
And my &foo is an outright syntax error. So the the lexical subs cannot truly be lexical subs but merely scalar references to CODErefs. But this introduces the problem of namespace issues e.gmy sub foo; __output__ "my sub" not yet implemented at - line 1.
Currently the workaround is distinctly horrid and involves inserting a double underscore around the variable name so $foo becomes $__foo__. I'm possibly missing some blatently obvious idea or maybe this is an inherent limitation of perl (and with good reason?).use Sub::Lexical; my $foo = "a string"; # ack, $foo = sub {}; will run over previous $foo :-/ my sub foo { print "I'm in foo()\n"; }
_________
broquaint
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Concurrent lexical scopes?
by Abigail-II (Bishop) on Jun 11, 2002 at 12:16 UTC | |
Re: Concurrent lexical scopes?
by broquaint (Abbot) on Jun 11, 2002 at 14:30 UTC | |
by Joost (Canon) on Jun 12, 2002 at 11:12 UTC | |
by broquaint (Abbot) on Jun 12, 2002 at 11:41 UTC | |
Re: Concurrent lexical scopes?
by Joost (Canon) on Jun 11, 2002 at 13:31 UTC | |
by broquaint (Abbot) on Jun 11, 2002 at 13:44 UTC | |
by Joost (Canon) on Jun 11, 2002 at 14:00 UTC |