On Tue, 2 Feb 2016, Graeme Geldenhuys wrote:
On 2016-02-02 09:07, Michael Van Canneyt wrote:
The "if then" construct is really confusing.
"if then" is a statement, not an expression.
Exactly! I'm glad somebody noticed that too.
I'm fine with the iif() syntax. It is used in a few languages for many
years, so is a common and known name.
Then again, I really don't know what the issue is here, because it is so
simple to implement your own in Object Pascal. For example, the tiOPF's
tiUtils.pas unit has had it for over 15 years now.
Try this (A a component or class with property Name):
N:=iif(Assigned(A),A.Name,'Nil');
You'll get a crash using regular functions because All arguments are
evaluated prior to calling iif().
If IIF() is an intrinsic, then the compiler will only evaluate the argument
that corresponds to the condition.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal