lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Roberto Ierusalimschy wrote:
The second is that there is no easy and simple way to avoid using
the dot notation for every reference to an "imported" object. Then I
presented an idea we have been discussing before (the "mechanism that
forces variable declarations").

We've come to it in a roundabout fashion, but it seems to me that the syntax

    global (T) *

would be better recognized as:

    namespace T

In other words, you've "invented" namespaces ;-). However I'm not sure I understood the intended semantics of your proposal, and am assuming two things: 1) the access rules apply not only when the module is executed, but also when functions defined within the module are executed, and 2) in nesting of dofile's/modules, the access rules properly nest.

  Public = {}
  global ({}) *
  global (Public) a,b,c

puts all new names into a private table, but a,b and c, that go to the
public table. (This builds something similar to my proposal for modules,
but you do not have to prefix all names with "Public." or "Private.".)

I am not sure this is an improvement over your LTN, the problem being that public names have to be maintained in two places and so prone to error. The "namespaces" take care of the privates nicely, but I would still prefer calling out the public table explicitly at the point of definition. (The same applies to globals, and it would be nice to have a shorthand for "globals().name", perhaps simply ".name"). I would also think that supporting the "qualified namespaces" (those with variable lists) will add some weight to your implementation.

If upvalues were any lesson, we'll end up with proper namespaces despite any contrary intentions ;-).


OpenPGP encrypted mail welcome.