[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: return value of require?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 28 Feb 2008 15:10:16 -0300
> "Jerome Vuarand" <email@example.com> writes:
> >> Is swig being bad by returning a string instead?
> > It's not following the informal convention used by most Lua modules. Is
> > it bad to be different ?
> My _impression_ is that this is at least a "convention", and AFIACT,
> swig has no good reason to be different (the value it returns seems
> fairly useless), so I'd say... yeah.
> But a quick look at PiL and the ref manual don't show any comment the
> issue, so I'm not really sure where I picked up this habit. I guess
> really I'm looking for advice on what the Lua community considers in
> good taste.
PiL2 says this:
From the user point of view, a module is a library that can be loaded
through require and that defines one single global name containing
a table. Everything that the module exports, such as functions and
constants, it defines inside this table, which works as a namespace.
A well-behaved module also arranges for require to return this table.
Also, the 'module' function follows this behavior.