Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Assigning void Date: Sun, 14 Oct 2012 14:09:24 +0200 Lines: 42 Message-ID: References: <1b846149-65a7-4482-b965-71e1fa7c6d75@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net bn8Af1KHnS27aLfjwicVRwx44fGyxkOLBgQuFzUvvqKh/j5znpbr+bMx4HtbqOqPM= Cancel-Lock: sha1:6YkDhgByM2II1sKkp7u5JBuXB3A= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 In-Reply-To: <1b846149-65a7-4482-b965-71e1fa7c6d75@googlegroups.com> Xref: csiph.com comp.lang.java.programmer:19323 On 13.10.2012 22:03, Lew wrote: > markspace 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 >> side-effecty. > > No true Scotsman. > > It isn't an implied assignment, it's an explicit one. > http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.14.2 > > Since it's the purpose of the operator, it's not "side effecty", it's > "direct effecty". 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: http://en.wikipedia.org/wiki/Side_effect_%28computer_science%29 > 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. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/