[chuck-users] ++ return value

Ge Wang gewang at CS.Princeton.EDU
Tue Jun 27 17:42:21 EDT 2006


Hi Atte!

The ++ and -- (post and pre) are a bit fishy right now.  We plan to fix 
this.
In the meantime, it safest to NOT used them inline with expressions.

Thanks for the reporting this and sorry for the inconvenience.

Best,
Ge!

> I expected the ++ (and --) operator to work as this:
>
> If ++ precedes the variable, e.g. ++i, the value returned is the value
> in counter after it has been incremented. If ++ follows the variable,
> e.g. i++, the value returned is the value in counter before it has been
> incremented.
>
> This doesn't seem to be the case (chuck always returns the value after
> it has been incremented):
>
> int i;
> <<<i>>>;
> <<<i++>>>;
> <<<++i>>>;
>
> [atte at aarhus tests]$ chuck increment.ck
> 0 :(int)
> 1 :(int)
> 2 :(int)
>
> Maybe this could be changed?
>
> -- 
> peace, love & harmony
> Atte
>
> http://www.atte.dk      | quartet:      http://www.anagrammer.dk
> http://www.atte.dk/gps  | compositions: http://www.atte.dk/compositions
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



More information about the chuck-users mailing list