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

Kamil Skalski nazgul at nemerle.org
Mon Sep 27 15:52:32 CEST 2004


Dnia poniedziałek, 27 września 2004 15:34, Marcin 'Qrczak' Kowalczyk napisał:
> Michal Moskal <malekith at pld-linux.org> writes:
> > Now, when the warning is optional, we can make ++ return value, there
> > is no problem with that. We could even make = return value, but I would
> > rather avoid this one (if (x = true) ... vs if (x == true) ...).
>
> What about the typing of
>
>    if cond then
>       ++i
>    else
>       something-of-type-void
>
> ?

The silent conversion of value to void should probably be done only when we 
know, that expression MUST have type void. 
One of the cases when it's true is inside the sequence
{ ....; expr; ... }

The case of `if (cond) e1 else e2' is the place where branches of condition 
should have the same type and there should be no implicit conversion.

It's not clear what about
if (cond) e;
here we also know, that e must have type void... 
-- 
Kamil Skalski
http://nemerle.org developer




More information about the devel-en mailing list