Hello FPC-Pascal,
Sunday, February 21, 2010, 9:32:50 PM, you wrote:
DWN> This is actually valid ALGOL 60 and/or ALGOL 68. Conditional DWN> expressions were available in both languages. I think Niklaus Wirth DWN> continued with this in ALGOL W, but dropped it from Pascal. DWN> Note that the ALGOLs required the "else" clause, as does C today (see DWN> below).
I'm the opposite of an compilers expert, also never learned Algol, modula, eiffel or non "main-stream" languages, except Forth. So I known my opinion is not an expert opinion, just an opinion only.
After this preamble :) I must say that this is Pascal, not Algol ;)
> Is it correct ? From my point of view is much more reasonable to use
> something like:
> z := iff(a=b,1,2);
DWN> This is over-punctuated Visual BASIC. Yuck.
iff is valid in VB ? Just a coincidence, I was trying to note the "if-function".
Show quoted text 5 lines
> But to me it looks awful and a bit of c-ism and really horrible code
> could be written:
> z: Boolean;
> begin
> z := iff(a=b,iif(b=2,a=b,ba),not(a=b));
DWN> Mega-yuck!!
I even do not know the result :)
DWN> I can only infer that you don't write C. The C equivalent is:
Oh yes, I write and wrote C/C++ that's the reason I hate such things, like:
if (a=a++==a) {......}
It's a funny entertainment to try to know which exactly that condition will execute.
DWN> z = a == b ? 1 : 2;
DWN> It's terse, but one gets used to it.
In near 20 years I was unable to find the reason and need of such constructions, even when my first computer only have 3 Kb for source code.
Best regards,
JoshyFun