[fpc-devel] new features and facilities

Sven Barth pascaldragon at googlemail.com
Fri Oct 9 08:08:51 CEST 2015


Am 08.10.2015 23:48 schrieb "Michael Van Canneyt" <michael at freepascal.org>:
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20151009/7659c325/attachment.html>


More information about the fpc-devel mailing list