Re: Assigning void
On 13.10.2012 22:03, Lew wrote:
I'd consider post-increment there a side effect, yet it's legal. Yes, I
know there's an implied (required) assignment there, but it's still
No true Scotsman.
It isn't an implied assignment, it's an explicit one.
Since it's the purpose of the operator, it's not "side effecty", it's
My memory might be a bit rusty but the definition of "side effect" that
I learned was that it is a state change not reflected in the result.
That includes IO for example, even if one could argue that the main
effect of System.out.println("foo") is to print "foo\n" on the console.
The definition of "side effect" I have in mind solely deals with a
distinction important in the context of functional languages. A side
effect free expression has some properties which go away when side
effects are introduced (thread safety, stability which has effects on
analysis of behavior etc.). The introductory paragraph on the Wikipedia
page nicely sums this:
Unless assignment through '=' is also "side effecty".
Yes, because variable assignment changes state. If you think about it,
statements in languages which have statements (additionally to
expressions) only make sense at all if there are side effects. A
statement (which doesn't have a result) in a language completely free of
side effects would do nothing - ever.
remember.guy do |as, often| as.you_can - without end