in reply to eval order of args to a sub
I think the general rule of thumb is, "don't." As in, don't modify parameters to a function in the line that calls the function in such a way that could be confusing.
If perl defined this, it would be one of very few languages that did so. And thus would still be confusing, IMO. It's not really that much extra work to avoid it. Use do if you have to:foo($i++); # ok foo(++$i); # ok foo($i,$i++); # not ok foo($i++,$i); # not ok foo($i++,++$i); # WTF?
my $flubber = do { my @args; push @args, $i++; push @args, ++$i; foo(@args) }; # well defined: $_[1] == $_[0]+2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: eval order of args to a sub
by shmem (Chancellor) on Jun 03, 2007 at 10:17 UTC |