in reply to Re: 'Dynamic scoping' of capture variables ($1, $2, etc.)
in thread 'Dynamic scoping' of capture variables ($1, $2, etc.)
Initial ( First ) callback of R() function:
$_='x55x666x7777x1x'; $_=undefined;
Inside code, after evaluating s/(\d+)// ? $1 + R() : 0;
$1=55; #immediately after executing s// command
Second callback of R():
$_='xx666x7777x1x'; $1=55;
Inside code, after evaluating s/(\d+)// ? $1 + R() : 0;
$1=666; #immediately after executing s// command
Third callback of R():
$_='xxx7777x1x'; $1=666;
Inside code, after evaluating s/(\d+)// ? $1 + R() : 0;
$1=7777; #immediately after executing s// command
Fourth callback of R():
$_='xxxx1x'; $1=7777;
Inside code, after evaluating s/(\d+)// ? $1 + R() : 0;
$1=1; #immediately after executing s// command
Fifth callback of R():
$_='xxxxx'; $1=1;
Inside code, after evaluating s/(\d+)// ? $1 + R() : 0;
# no callback executed as ( there are no digits ) pattern not matched
$1=undefined; #immediately after executing s// command
# after prints 'xxxxx' and '1' for fifth callback
# after prints 'xxxxx' and '1' for fourth callback
# after prints 'xxxxx' and '1' for third callback
# after prints 'xxxxx' and '1' for second callback
# after prints 'xxxxx' and '1' for first callback
Kindly regret me for format. I unable to get exact stack of recursive calls for presentation.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: 'Dynamic scoping' of capture variables ($1, $2, etc.)
by moritz (Cardinal) on Dec 18, 2012 at 14:22 UTC | |
by nvivek (Vicar) on Dec 19, 2012 at 05:13 UTC | |
by moritz (Cardinal) on Dec 19, 2012 at 06:21 UTC | |
by nvivek (Vicar) on Dec 20, 2012 at 07:16 UTC |