[fpc-devel] bug: Inc(v,i)/Dec(v,i)

Gerhard Scholz gs at g--s.de
Fri Jul 8 14:24:30 CEST 2005


----- Original Message -----
From: "Vinzent Hoefler" <JeLlyFish.software at gmx.net>
To: "FPC developers' list" <fpc-devel at lists.freepascal.org>
Sent: Friday, July 08, 2005 1:24 PM
Subject: Re: [fpc-devel] bug: Inc(v,i)/Dec(v,i)


...
> Agreed. It's not readable at all. So don't do that, instead
>
> {$IFDEF BIG}
> type My_Type = SmallInt;
> {$ELSE}
> type My_Type = ShortInt;
> {$ENDIF}
>
> and then
>
> |Inc (My_Type(v), Delta);
>
> should do the trick.

It's not so easy because v is of subrange x..y where x and y are more
complex constant expressions. So I would have to check that with a lot of
{$if } to decide between short and small. Makes it also unreadable.

> OTOH, ...
new abbreviation? what's that?

> ... to be honest: I don't see the point in using Inc/Dec here at all,
> especially if "v := v + Delta;" would work perfect already. I even
> think the "standard" way of doing the addition would be much more
> readable in that context.

I'm already doing that (now).

With some accustomization, "inc(..." and "v := v + ..." is both good
readable, and normally (at least with checks off) it was assumed to produce
compacter and faster code. Especially when v is not a simple variable, but a
more complex one, e.g.:
    Inc ( v[j]^[k].a[l], delta ) ;
And in such a case it's also better readable.

Gerhard







More information about the fpc-devel mailing list