in reply to RE: RE: (Ovid) RE(2): modify variable on pass by value
in thread modify variable on pass by value

Funny you should bring up chop again.

In the classes I teach, the fact that chop acts on its arguments is one of the most difficult things for students to keep straight. I see people writing all the time:

$a = chop $a;
It's precisely because chop is so different from the rest of Perl that people get it wrong. So I'm not in favor of encouraging people to write more things like chop.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
RE: RE: RE: RE: (Ovid) RE(2): modify variable on pass by value
by chromatic (Archbishop) on Sep 11, 2000 at 21:13 UTC
    That surprises me a little. I'd assume people would have more trouble with that because the addition and assignment statement appears to violate algebraic rules:

    $a = $a + $b;

    Obviously Larry's thought about that before, which is why we have:

    $a += $b;

    instead. Once they wrap their heads around the former, the inconsistency of chop trips them up again? Interesting.