On 02/02/2016 11:42, fpc-pascal-requ...@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
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to