[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: return value of require?
- From: Doug Rogers <rogers@...>
- Date: Thu, 28 Feb 2008 12:50:06 -0500
Miles Bader wrote:
> "Jerome Vuarand" <firstname.lastname@example.org> 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.
I agree. It's not bad to be different in general. But if one intends for
others to use his product then he should have a good reason for breaking
> 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.
You are correct to expect that behavior. PiL's complex number example
returns its method table. And the description of the module function in
15.4 shows how the module's table is placed in package.loaded, which is
returned by require.
But there's no general enforcement, which is good, and which is why you
ran into the strange swig behavior.
Innovative Concepts, Inc. www.innocon.com 703-893-2007 x220