[nem-en] incorrect side effect of ++ operator
Kamil Skalski
nazgul at nemerle.org
Mon Sep 27 17:56:08 CEST 2004
Dnia poniedziałek, 27 września 2004 17:39, Radek Jedrasiak napisał:
>
> > Just do
> > ++i;
> > Console.WriteLine( "{0}", i );
>
> How about a macro replacing the ++ prefix operator and ++ postfix operator
> with the coresponding blocks? That way the return types of assignments
> could be left to be void and there would still be less trouble with
> all the people who got used to the way i++ and ++i work (don't forget about
> -- ;-)
Well, it would be possible and maybe even not so hard with currently available
traversal functions for parsetree. But it seems very hackish... and sometimes
would need to do complex transoformations
foo (i, ++i) ====> ++i; foo (i, i); ?
this would force us to do
def prev = i; ++i; foo (prev, i);
but
foo (i, ++i, ++i, ... ) would again complicate things
and foo (i, ref i, ++i) ....?
It's better to change the way programmers use it, than adding some strange
background transformation.
Maybe there should be warning then somebody use void in parameter with more
overloads than only object?
--
Kamil Skalski
http://nemerle.org developer
More information about the devel-en
mailing list