Am 08.10.2015 23:48 schrieb "Michael Van Canneyt" <[email protected]>:
> Actually, yes I think C's or Javascript's ternary is better suited.
>
> Let me explain. If I see
>
> If expr1 then expr2 else expr3
>
> it says 'statement' to me. But
>
> a ? b : c;
>
> Says "expression" to me.
>
> So
>
> left := a ? b : c;

That's probably only because other languages use that as the ternary.

There also another reason why I prefer the variant with the if: ease to
implement in the compiler.

For the if one merely needs to add a corresponding case in factor() while
for the ?: one needs to fiddle with the compiler's operator precedence
rules that are applied in sub_expr() which can lead to desaster either
during implementation or later on when bugs are discovered...

So that's another reason why I'm inclined to this...

(Also that Algol-60 as the spiritual predecessor of Pascal has them as well
is quite intriguing :) )

Regards,
Sven
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to