lua-users home
lua-l archive

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


Ahh, of course! Silly me. Thanks for the clarification.

On Apr 20, 2013 11:57 PM, "Choonster TheMage" <choonster.2010@gmail.com> wrote:
On Sun, Apr 21, 2013 at 4:55 PM, Mark Gabby <mwgabby@gmail.com> wrote:
> To whit:
>
> local function f(t, var)
> print(var)
> end
>
> f(3, x or 2)
>
> Prints 2 in Lua 5.1. Wouldn't have thought of doing that though, thanks for
> the idea! This is a great idiom.
>
> (Am I missing something? Would your patch catch some case this wouldn't work
> with?)
>
> On Apr 20, 2013 11:41 PM, "Dirk Laurie" <dirk.laurie@gmail.com> wrote:
>>
>>     function f(x,y=0)
>>     function f(x,y or 0)
>>
>> to mean
>>
>>     function f(x,y) y=y or 0
>>
>> Neither would break existing code.
>>
>> Which of the above should I choose to implement as a patch?
>>
>

I think Dirk wants to patch the behavior into the function definition,
not the function call.