Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: The Assignment Principle Date: Sun, 26 Jan 2014 15:39:16 -0500 Organization: A noiseless patient Spider Lines: 27 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 26 Jan 2014 20:39:12 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="8228"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193o42ijsEoueuJYYRwhyrS" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: Cancel-Lock: sha1:1+HONkGpWkZDI6WtDTpLDntmRPA= Xref: csiph.com comp.lang.java.programmer:27402 On 1/26/2014 3:17 PM, Stefan Ram wrote: > I once read the »Assignment Principle«. It says that after > an assignment a comparison with the assigned value yields > true. Assuming v was declared properly: > > v = 2; > java.lang.System.out.println( v == 2 ); // prints true > > I think we can assume a single thread of execution and > normal memory [not I/O registers or so]. Also, it is > about values and not expressions, so that > > v = java.lang.Math.random(); > java.lang.System.out.println( v == java.lang.Math.random() ); > > is not a counterexample. > > Being cautious, I'd like to ask: Do you see any exceptions, > where this does not hold? (I suggest to reply only if the > answer to that question is »yes«.) double x = Double.NaN; assert x == NaN; // ka-BOOM! -- Eric Sosman esosman@comcast-dot-net.invalid