Affichage des articles dont le libellé est Principle. Afficher tous les articles
Affichage des articles dont le libellé est Principle. Afficher tous les articles

dimanche 26 janvier 2014

The Assignment Principle topic




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
(E-Mail Removed)d