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

Serguei TARASSOV serge at arbinada.com
Tue Feb 2 12:03:07 CET 2016


On 02/02/2016 11:42, fpc-pascal-request at lists.freepascal.org wrote:
> On Tue, 2 Feb 2016, Sven Barth wrote:
>
> >No, the second is always better because safer.
> >
> >x := iif (Obj = nil, 0, Obj.Value);
> >This will raise access violation as a normal function or you depend on
> compiler implementation for this special case. And you should remember an
> additional special case of function.
>
> That's why the current IfThen() is an intrinsic, to allow this.
Why make the things complex? Why create another "special case"?
Look at the "iif" as an statement and the things will be simple.
>
>> >x := iif Obj = nil then 0 else Obj.Value;
>> >Doesn't raise AV because it's a statement, not function.
> It's not a statement, it's an expression. Also I won't introduce a new
> keyword ("iif") just for this.
Disagreed.
The principal difference between the statement and the expression is 
that the expression doesn't control the execution flow.
In this "expression" you simply hide the statement to the semantic 
analysis level.
> Regards,
> Sven
Regards,
Serguei



More information about the fpc-pascal mailing list