lua-users home
lua-l archive

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


On Fri, Sep 10, 2010 at 10:15 PM, Patrick Donnelly <batrick@batbytes.com> wrote:
> On Fri, Sep 10, 2010 at 5:01 PM, Roberto Ierusalimschy
> <roberto@inf.puc-rio.br> wrote:
>>> On Fri, Sep 10, 2010 at 2:42 AM, David Kastrup <dak@gnu.org> wrote:
>>> > Do you really think you can keep children from growing up?
>>>
>>> Can you be less cryptic please, and explain what you think the
>>> long-term issues are? I think this is a useful addition too.
>>
>> I have an issue, but I am not sure it is a "long-term" one. I think
>> the proposed syntax, without "end", will be quite confusing to some
>> people, given that the almost identical if command must have "end".
>> On the other hand, a syntax with "end" is cumbersome.
>
> I believe the "if" looks nice but is unnecessary and may be confusing.
> Something like:
>
> a = b then x else y
>
> would be shorter (after all, isn't that the reason we do this?). I
> think a better choice for the ternary operator keywords would make it
> even clearer. I considered something like this:
>
> a = x when b else y

Or even 'x if b else y' - even shorter and does not require a new keyword.

> That messes up the usual order so it's unlikely to be accepted.

I don't know, Lua is already relatively unusual in a lot of ways.

> For what it's worth, I'm definitely in the boat that we need a builtin
> ternary operator. The "b and x or y" idiom is just too confusing to
> newcomers. Most don't ever learn what it really means and get bitten
> by bugs when x is false/nil.

I think it's a good idea, too

-Duncan