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

It seems that the author of the question wants symantics that are like chop. People know what chop is going to do to their variable. If the user is well aware of the way the subroutine will work, is it all that bad? Since you would have to do that with chop anyway?

Just one guy making conversation with someone who's been coding for 30+ years (honest). {grin}

--
Casey
  • Comment on RE: RE: (Ovid) RE(2): modify variable on pass by value

Replies are listed 'Best First'.
RE: RE: RE: (Ovid) RE(2): modify variable on pass by value
by merlyn (Sage) on Sep 11, 2000 at 20:47 UTC
    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

      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.