[fpc-pascal] New feature: IfThen() intrinsic

Sven Barth pascaldragon at googlemail.com
Mon Feb 1 21:10:30 CET 2016


On 01.02.2016 21:02, silvioprog wrote:
> On Mon, Feb 1, 2016 at 4:47 PM, Sven Barth <pascaldragon at googlemail.com
> <mailto:pascaldragon at googlemail.com>> wrote:
> 
>     On 01.02.2016 20:33, Marcos Douglas wrote:
>     > On Mon, Feb 1, 2016 at 5:06 PM, David Butler <djbutler at gmail.com
>     <mailto:djbutler at gmail.com>> wrote:
>     >> Speaking personally, the reason why I like Pascal syntax over C
>     is exactly
>     >> because it isn't short. I prefer the verbosity of Pascal rather than
>     >> "cryptic" syntax of the C family. e.g. Pascal uses "function" not
>     "func",
>     >> "procedure" not "proc", "if then else" not "if ()", etc. Using
>     short C-like
>     >> syntax in Pascal goes against the long established style of Pascal.
>     >
>     > +1
>     >
>     > IMHO we can't use "IfThen" (or iif, IfThenElse, etc) as if it were a
>     > real function, because it is not.
>     >
>     > So, according to the "spirit of Pascal, what do you think about this?
>     >
>     >
>     > V := inline If Condition then ThenExpr else ElseExpr;
>     >
>     >
>     > Only "inline" keyword will be introduced.
>     > But I don't know if will be more hard to implement this.
> 
>     If we would go the route of such an if-expression instead of an
>     intrinsic then just leave away the "inline". That's absolutely not
>     needed... (Note: implementation wouldn't be hard at all)
> 
> 
> When you format this code (e.g using Ctrl+D) the result is a very ugly
> syntax:
> 
> var
>   S: string;
>   B: Boolen = True;
> begin
>   S :=
>     if B then
>       'A'
>     else
>       'B';
> end;
> 
> And I think that it breaks compatibility with many Pascal syntax
> beautifier. IMHO Iif() (or something like this) sounds better.

I honestly don't care about syntax beautifiers, like at all. Most are
already broken for ObjFPC anyway.

Regards,
Sven




More information about the fpc-pascal mailing list