The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
* The reasoning behind sub NAME { } constructs being realized early is so that you can call subroutines even if their definition is "later" in the code. That's mostly true, but not very precise. If a subroutine is defined after it is called, the call has to use parenthesis. If it doesn't, it's interpreted as a string literal (or as an error if strict subs are in effect).
However it the call uses parenthesis, there's no need it has to be know at compile time at all:
But I think for this discussion it's more important to ask when the lexical pad of sub a is being built and destroyed. As long as the a is not part of the call chain, $x is in no lex pad, and sub b can't work in a meaningful way.
Perl 6 - links to (nearly) everything that is Perl 6.
In reply to Re^3: Defining a sub within a sub: OK?
by moritz
|
|