in reply to Re^2: Perl vs C
in thread Perl vs C
In Perl, sub x (--$i, $i++) behavior is also undefined
Not really. On all platforms, operands are always evaluated from left to right except for assignment operators, where it's right to left. People regularly rely on this.
sub foo { shift->bar('foo', @_)) }
{ my $x = $x; ... }
The latter is even documented.
The problem is that it gets really tricky when lvalues are involved.
The first argument is evaluated first, but it's still affected by the decrement because Perl passes by reference.f($i, --$i, $i);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Perl vs C
by Marshall (Canon) on Mar 14, 2009 at 20:34 UTC | |
by ikegami (Patriarch) on Mar 14, 2009 at 23:04 UTC |