[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Modules, interfaces
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 11 Apr 2012 10:31:07 +0200
>>> local module_list = {
>>> require ("m"),
>>> require ("n"),
>>> require ("q"),
>>> }
>>> print (#module_list) -- The printed value will be "4"
>>
>> Nope. Only the first return value would be kept in a table constructor.
>
> ... except for the last value: if require 'q' returns multiple values,
> they'll all be put into the table.
>
> The real problem with returning multiple values from a module is that
> "require" only returns one value, regardless of what the module does...
>
The last sentence made me wonder whether the "if" clause in the previous
sentence could ever be true. And of course it can, "require" is merely
a predefined name. Nothing stops you from writing this:
function require(x) return x,x+1,x+2 end
s={require(100)}
print(#s) --> 3
(However, if you do that sort of thing, please don't ask me to help you
debug your code, ever.)
- References:
- Modules, interafaces, Jorge
- Re: Modules, interafaces, Rebel Neurofog
- Re: Modules, interfaces, Jorge
- Re: Modules, interfaces, Rebel Neurofog
- Re: Modules, interfaces, Rena
- Re: Modules, interfaces, Miles Bader