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

Lukasz Sokol el.es.cr at gmail.com
Tue Feb 2 17:28:17 CET 2016


(bikeshedding mode=on)

On 02/02/16 11:24, Marcos Douglas wrote:
> On Tue, Feb 2, 2016 at 7:49 AM, Michael Van Canneyt
> <michael at freepascal.org> wrote:
>> It is not a statement, it is an expression.
>>
>> I prefer
>>   x := iif Obj = nil then 0 else Obj.Value;
>> over
>>   x := if Obj = nil then 0 else Obj.Value;
>>
>> Because it clearly differentiates between if (a statement) and iif (an
>> expression)
>>
>> So the iif in either functional or expression form has my vote.
> 
> +1
> 
> And why not use 'inline'?
> 
>   x := inline if Obj = nil then 0 else Obj.Value;

and what if the definition was

x := (if condition then value1 else value2);

that is REQUIRING round parentheses around this construct - 
no need for 'inline' keyword and compatible with code beautifiers (of sorts) 
and thanks to parentheses, showing exactly it's a statement, returning a value like an expression...

> 
> It's not necessary add one more keyword like "iif", I think.
> 
> Best regards,
> Marcos Douglas

el es





More information about the fpc-pascal mailing list