lua-users home
lua-l archive

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


On Tue, Dec 16, 2014 at 6:59 PM, Sean Conner <sean@conman.org> wrote:
> It was thus said that the Great Sean Conner once stated:
>>
>>   which immediately shows a problem (or at least I see a problem):
>>
>>       function foo(x,y)
>>         local x,y = x or return nil,"error",y  --- ... um ...
>>       end
>>
>>   Question:  if you call foo(nil,3) does this return nil or nil and "error"?
>> If you call foo(2,2) is x 2 and y "error", or 2?  Well, parenthesis can
>> clear that up:
>>
>>       local x,y = x or (return nil,"error") , y
>
>   Actually, the parenthesis may not fix the problem---that might require
> another language change.  But *this* is allowed:
>
>         local x,y = x or return nil,"error";,y
>
>   So we're still good.
>
>   -spc (Um ... more or less ... )
>
>

My reaction to this is: "Every idea is awesome, provided that you
don't think about it too much!"

That is: Thanks Sean. I think that's about as far as I wanted to take
this (others can feel free to keep thinking about this / posting).

Reading your grammar, which I don't know how to read without much
guessing, I can see that this would complectificate things.

Issues that are like "what happens with multiple returns?" can easily
be answered with "you can't", as it is in other circumstances. So
those kinds of issues aren't always so bad, but if there are any big
ones, then one goes back to wondering if it's worth it, which is
perhaps why it's not already so...

But, then again, nothing presented thus far makes me overtly hate it
either. On balance, even with clear restrictions, I would use it. Its
absence isn't the most verbose thing about Lua. :)

Again, thank you. You've given me a little bit to study. Now I'm on to
Wikipedia / the interwebs to learn how to read the notation. Also, if
I want to play with this, I should take my own past advice and hack
something up...

-Andrew