brewer has asked for the wisdom of the Perl Monks concerning the following question:
When you construct a call to a function, e.g. solve_problem($problem, $parameter) is it in anyway correct or useful to consider that you are constructing the @_ list array that will be available in the function with the part in braces, just as you would write @array = ($problem, $parameter) ?
I hope that makes sense - as a bit of background, I thought
of it when asked why the following two uses of sort didn't
work the same way:
The first use clearly matches 'sort SUBNAME LIST', but the second one looks like plain old 'sort LIST'.my $sort_func = sub { $a <=> $b }; sort $sort_func @to_be_sorted; # Sort 1 sort ($sort_func, @to_be_sorted); # Sort 2
Is this analysis correct? Could thinking like this ever lead to confusion?
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Function calls and list creation
by tcf22 (Priest) on May 31, 2003 at 00:19 UTC | |
by chromatic (Archbishop) on May 31, 2003 at 00:28 UTC | |
by tcf22 (Priest) on May 31, 2003 at 00:37 UTC | |
by brewer (Sexton) on May 31, 2003 at 01:00 UTC | |
by brewer (Sexton) on May 31, 2003 at 00:45 UTC |