News for hackers. Stuff that matters.
Re:Should function arguments be reassignable or mutable? by maxxxxx on Monday January 01, 2018 @10:56AM (#16046499)
Why would they allow this? Is there any legitimate case where doing this makes sense? Seems very risky to me. In most languages I know you would expect that the "a" variables are the same.
Re:Should function arguments be reassignable or mutable? by christophilus on Monday January 01, 2018 @11:36AM (#16046678)
In the past, I've used it in order to ensure the variable has a legitimate value. So, something like this (pseudo code):

    fn foo(a):
      a = a |> trim |> (default "chocolate")
      mix a "milk"

Well, in this contrived example, I wouldn't reassign a, just tack on `|> (mix "milk")` but in a complex example where you're reusing `a` in several places, it can make sense and is nicer than having to declare a bunch of variables just to hold the sanitized values of arguments.
Re:Should function arguments be reassignable or mutable? by maxxxxx on Monday January 01, 2018 @01:27PM (#16047250)
Looks like you are using it as a reassignable function argument. Makes sense.