[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: package proposal
- From: David Jones <drj@...>
- Date: Thu, 30 Sep 2004 16:56:58 +0100
On Sep 30, 2004, at 13:49, Roberto Ierusalimschy wrote:
1) Distinction between packages and modules seems unnecessary. Allow
module A to drag in other modules if necessary.
This can lead to some confusion. How do we distinguish between package
(the whole tree rooted at A) and module A (only the A node)?
Er, you don't.
Let's say I have drj.debug.trace and drj.debug.memory, two modules.
Basically what I'm saying is that you permit me to implement a module
drj.debug such that when I << require'drj.debug' >> it sucks in
drj.debug.trace and drj.debug.memory .
I'm not really expecting any useful functionality to be implemented in
the interior (non leaf) nodes of the module name tree, so I don't want
to be able to << require'drj.debug' >> without sucking in the other
modules as well. I guess you would call drj.debug a package, but it
doesn't seem that useful a distinction to me. I suppose I might have
some generic audio filter code at audio.filter and some specific
implementations at audio.filter.noise and audio.filter.kalman and so
on. It then might be useful (if I was a module implementing a filter)
to requite audio.filter but not get all of the modules therein. Is
that the sort of thing you had in mind?
When might I have a package that has the same name as a module? And
would it be useful to require the module alone without getting the rest
of the package as well? I can't think of any good example, but maybe
I'm just being unimaginative.
2) Can we have "./?;" in the default package.path like require
Sure ("./?.lua" seems better).
I agree. It's a minor niggle. Just doesn't seem much point in not
implementing the current behaviour.
It seems undesirable that I should be able to go << require'trace'
and the module gets plonked in the global trace, but if I go <<
require 'Trace' >> is still works, but the same module gets plonked in
the global Trace.
Lua itself is case sensitive, so it makes sense to get a Trace global
if you write require"Trace" and a trace global if you write
Therefore you should write always with the same capitalization. The
"problem" with a case-insensitive file system is that you do not get an
error message when you write it wrong. That does not seem too bad.
Well, a module system is where a language meets the file system (or is
that a package system?), so I don't think you can brush away such
issues so lightly by saying "Lua itself is case sensitive". The issue
is when I say << require"Trace" >> does "Trace" refer to a Lua variable
name (conceptually I can think of all possible Lua modules as being at
some particular place in my Lua state's global namespace and I bring
them into existence at that place by using require) or does it refer to
a location in my file system (conceptually I think of all Lua modules
that I have placed in my file system and I create them in my Lua state
by using require). In the former case "Trace" should act like a Lua
variable and so be case-sensitive, in the latter case "Trace" should
act like a filename, and so do whatever the file system does.
A related issue is: do you think Lua modules have canonical names? Or
is the name of the module (where it gets placed in the global namespace
of a Lua state) down to how a user gets it via the file system and