[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Packaging, 2 last concerns
- From: Jamie Webb <j@...>
- Date: Fri, 11 Jun 2004 19:50:35 +0100
On Friday 11 June 2004 19:28, firstname.lastname@example.org wrote:
> > What you could be saying is that modules should not export variables,
> > only constans and functions. (Or, as Asko wrote, they should be
> > read-only.) There are lots of people who aggree with that idea.
> This is not really a problem with exported variables. It's a problem
> with any context the library want's to keep, regardless of whether it is
> exported directly, accessible through a method or not exported at all.
> Without imposing some kind restriction on how library functions are
> exported, I don't think there is a solution for this problem (maybe
> having socket:connect(...) instead of socket.connect). I am not
> comfortable forcing libraries *not* to keep any context either.
> Perhaps it's better to forget the lazy namespace instantiation,
> unless you can come up with some way to do a deeper copy-on-write that
> would copy through closures too (blergh).
Why do you want to copy any namespaces other than the ones built into Lua,
lazily or otherwise? Surely each module should be given a completely fresh
environment and be expected to require any modules it depends on. I thought
the agreed scheme (re-executing the module chunk every time the module is
required) would work perfectly well in that situation and give each owner its
own copy of any module internal state.
-- Jamie Webb