[nem-en] incorrect side effect of ++ operator

Wiktor Zychla wzychla at vulcan.edu.pl
Mon Sep 27 14:18:11 CEST 2004


the side effect of the ++ operator is, in my opinion, incorrecly used in 
following scenario.

class Hello
{
 static Main() : void
 {
  mutable i=0;
  Console.WriteLine( "{0}", ++i );
 }
}

output: empty

is such behaviour consistent with Nemerle semantics or is it a bug?
if it is not a bug, then I think that the semantics should be revisited 
because it's nonintuitive.

IL:
ldc.i4.0
stloc.0            // i=0
ldstr      "{0}"
ldloc.0
ldc.i4.1
add.ovf
stloc.0           // i=i+1
ldnull             // this is why the output is empty
void [mscorlib]System.Console::WriteLine(string, object)
ret

Regards,
Wiktor 






More information about the devel-en mailing list