[fpc-devel] new features and facilities

Martin Frb lazarus at mfriebe.de
Fri Oct 9 02:04:21 CEST 2015

On 08/10/2015 23:18, Mark Morgan Lloyd wrote:
> Michael Van Canneyt wrote:
>> Let me explain. If I see
>> If expr1 then expr2 else expr3
>> it says 'statement' to me. But
>> a ? b : c;
>> Says "expression" to me.
> The way I look at it is that it's restoring a feature that was 
> (possibly accidentally) dropped during the ALGOL -> Pascal transition. 
> As such I don't have any problem with ALGOL-style
> left := if a then b else c;

Well if it is merely a decision between syntax: FPC already as a command 
line option for c like operator += -+ ..., so the ? could be only if c 
like ops are enabled.

Besides this, if ?: is treated like any operator then you can also use 
it in values for default param, or const

const bar = 1;
const TVal = 2;
const TVal2 = 3;
procedure foo(a: integer = 7 = bar ? TVal : TVal2);
const foo: integer = 7 = bar ? TVal : TVal2;

Which is hard enough to read. The meaning of the colon in the 
declaration block changes, if preceded by a ?

Of course the if can be made misleading too, if you break lines in the 
wrong place
   foo := SomeBoolValOrExpression +
   if a= b then bar(1) else bar(2);

More information about the fpc-devel mailing list