On Sun, 21 Feb 2010 20:37:12 +0100, JoshyFun wrote about Re[2]: [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 below). > 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; > begin > z := iff(a=b,iif(b=2,a=b,b<>a),not(a=b)); Mega-yuck!! 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. -- Regards, Dave [RLU #314465] ======================================================================= david.w.n...@ntlworld.com (David W Noon) ======================================================================= _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal