lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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