[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ternary operator patch
- From: Patrick Donnelly <batrick@...>
- Date: Fri, 10 Sep 2010 17:15:35 -0400
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
That messes up the usual order so it's unlikely to be accepted.
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.
--
- Patrick Donnelly
- References:
- Re: Ternary operator patch, steve donovan
- Re: Ternary operator patch, Henk Boom
- Re: Ternary operator patch, steve donovan
- 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