[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Multiple return values from require()
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Mon, 19 Oct 2009 11:53:33 +0200
2009/10/18 Matthias Kluwe <mkluwe@gmail.com>:
> Hi!
>
> 2009/10/17 Peter Cawley <lua@corsix.org>:
>> On Sat, Oct 17, 2009 at 7:01 PM, Matthias Kluwe <mkluwe@gmail.com> wrote:
>>> Hi!
>>>
>>> 2009/10/17 Linker <linker.m.lin@gmail.com>:
>>>> You can return a table instead of a list .
>>>
>>> Well, I know ... I can return _one_ table, but matrix.lua does return
>>> two of them, and there has to be a trick (well, not a trick obviously,
>>> but I can't find it in the reference manual).
>>
>> Look at http://www.lua.org/source/5.1/loadlib.c.html#ll_require - you
>> will notice that all execution paths terminate with an error or
>> "return 1;", hence require() can only return a single value.
>
> Right. I was mislead by the above mentioned script which I assumed to
> work. I checked now -- it does not.
If that's an old script, it may have worked in a previous version of
Lua (5.0 had a different 'require' function).