[nem-en] Increment and decrement operators

Michal Moskal michal.moskal at gmail.com
Sun Feb 26 22:04:00 CET 2006


On 2/26/06, Kamil Skalski <kamil.skalski at gmail.com> wrote:
> > Do you have any patches for +++?
>
> You mean
>
> macro @+++ (expr) {
>    <[ def x = $expr;
>        $expr = $expr + 1;
>        x
>    ]>
> }

What about overloaded op_Increment?

> > I just wonder if it won't screw up things like:
> >
> > if (...)
> >   i++
> > else
> >   ()
> >
> >
>
> t.n:12:4:12:6: error: expected int-, got void in computation branch:
> int is not a subtype of void [simple require]
> t.n:12:4:12:6: hint: this means two branches of ``if'' or ``match''
> have different types
>
> for
> --------------------------
> mutable i = 0;
>
> def f () {
>   i = i + 1;
>   i
> }
>
> if (true)
>    f()
> else
>    ()
> -------------------
>

So it does screw this up. I'm not sure we want to have it working *that* way...

--
   Michal Moskal,
   http://nemerle.org/~malekith/



More information about the devel-en mailing list