[fpc-pascal] some new features to delphi prisem
David W Noon
david.w.noon at ntlworld.com
Sun Feb 21 21:32:50 CET 2010
On Sun, 21 Feb 2010 20:37:12 +0100, JoshyFun wrote about Re:
[fpc-pascal] some new features to delphi prisem:
> Sunday, February 21, 2010, 7:29:54 PM, you wrote:
> MK> This is a matter of taste, I can imagine uses when at least
> MK> functional "if" would make code *more* readable. Noone forces
> MK> programmers to convert all their case/if to functional versions
> MK> if they look unreadable. The functional variants are supposed to
> MK> be used in particular situations, when they make sense.
> For me the bigger problem is that both statements change its behavior
> in function of its context.
> if a=b then 1 else 2;
That is an attempt at a statement, but what is being offered in Prism
is an enhanced *expression* syntax.
> this is a pascal error, but
> z := if a=b then 1 else 2;
This is actually valid ALGOL 60 and/or ALGOL 68. Conditional
expressions were available in both languages. I think Niklaus Wirth
continued with this in ALGOL W, but dropped it from Pascal.
Note that the ALGOLs required the "else" clause, as does C today (see
> Is it correct ? From my point of view is much more reasonable to use
> something like:
> z := iff(a=b,1,2);
This is over-punctuated Visual BASIC. Yuck.
> But to me it looks awful and a bit of c-ism and really horrible code
> could be written:
> z: Boolean;
> z := iff(a=b,iif(b=2,a=b,b<>a),not(a=b));
I can only infer that you don't write C. The C equivalent is:
z = a == b ? 1 : 2;
It's terse, but one gets used to it.
Dave [RLU #314465]
david.w.noon at ntlworld.com (David W Noon)
More information about the fpc-pascal