[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ternary operator patch
- From: David Kastrup <dak@...>
- Date: Thu, 16 Sep 2010 09:02:14 +0200
Ryota Hirose <hirose.ryota@gmail.com> writes:
> Hello Lua Hackers,
>
> 2010/9/16 David Kastrup <dak@gnu.org>
>
> > In the view point of the parser, the logical operator 'and' has
> > higher priority than 'or', but, for programmers, a ternary
> operator
> > must have lower priority than logical operator.
>
> Why?
>
>
> Because, the first operand of a ternary operator is a conditional
> expression. In a conditional expression, we want to use logical
> operators frequently, and unnecessary parenthesis are unwelcome.
You have conveniently snipped the rest of my post.
I wrote:
Lua has quite fewer operator priorities than C (and Pascal has even
fewer), and I should like to see evidence that more people get
confused by the operator priorities of Pascal than those of C.
C has perfected avoidance of the "unnecessary parenthesis" to the degree
where compilers warn if you actually make use of the fine-grained
priorities, as you are more likely than not to get them wrong.
--
David Kastrup
- References:
- Re: Ternary operator patch, Henk Boom
- Re: Ternary operator patch, Geoff Leyland
- Re: Ternary operator patch, steve donovan
- Re: Ternary operator patch, Miles Bader
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Miles Bader
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Jonathan Castello
- Re: Ternary operator patch, Roberto Ierusalimschy
- Re: Ternary operator patch, Enrico Tassi
- Re: Ternary operator patch, Doug Rogers
- Re: Ternary operator patch, Ryota Hirose
- Re: Ternary operator patch, Ryota Hirose
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Miles Bader
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Ryota Hirose
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Ryota Hirose
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Ryota Hirose