This is the mail archive of the
xconq7@sources.redhat.com
mailing list for the Xconq project.
Re: GDL Notice: Arithmetic Operators / Quasi-Formulae
Jim Kingdon writes:
> > These have now been added and work fine. Here is a frivolous example:
> > (define VILLAGE_STORAGE_MULT (+ (- 5))) ; evaluates to 5
> > ; because 5 - 1 = 4, and then 4 + 1 = 5
>
> Hmm. I didn't notice this the first time through, but this doesn't
> read so well. (- 5) looks like -5.
>
> I suppose
>
> (++ 5) => 6
>
> might be better, although of course it isn't like the C ++ because it
> just returns the incremented value, rather than assigning.
>
> There's also
>
> (inc 5)
>
> Or of course going back to (+ 5 1) if all of these choices seem
> problematic.
Actually I would prefer the (Common) LISP version:
(1+ 5) => 6
(1- 5) => 6
while
(+ 5) => 5
(- 5) => -5
This avoids overloading of + and -, but that's just IMO.