in reply to Re^3: map in void context
in thread map in void context

I don't consider assignment to have a "side effect". Assignment is the effect.
So,
map {$sum += $_} @array;
is side-effect free?

Replies are listed 'Best First'.
Re^5: map in void context
by JadeNB (Chaplain) on Dec 18, 2008 at 01:47 UTC
    I don't consider assignment to have a "side effect". Assignment is the effect.
    So,
    map {$sum += $_} @array;
    is side-effect free?
    This seems disingenuous. While I agree that arguing that assignment is “side-effect free” seems a little strange, your example isn't just assigning, it's mutating. Even in the purest of functional languages, x = 5 is OK (I think!); but x += 1 isn't.
      In a pure functional language, there is no assignment (there are no variables either - there are identifiers, but their values don't vary over time). x = 5 isn't an assignment. It just means that x is 5. Unlike an assignment which says that x becomes 5 (meaning that it could be something else before, and may become something else later).