[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: "namespaces" ?
- From: Edgar Toernig <froese@...>
- Date: Thu, 18 Apr 2002 19:55:16 +0200
Thatcher Ulrich wrote:
> On Apr 18, 2002 at 03:09 -0000, kaishaku13 wrote:
> > > It's essentially that sin is now called math.sin etc.
> > And how will this discipline be implemented? metatables?
> > I assume this is the only way but want to make sure...
> Just regular tables, I think -- no new features needed. There's a Lua
> Technical Note that describes the convention.
Some metatables will be needed to make i.e. the announced
f:read (instead of io.read(f)) possible. Where it becomes
interesting is how they make these 'methods' work on standard
types as these don't have metatables. I.e.:
PS: I would suggest longer names for the namespaces. I.e.
'File' instead of 'io', 'String' instead of 'str' etc.
In Sol I decided that "namespace" names should use mixed
case letters starting with an upper case one (Number, String,
Table, Function, Userdata, Nil, File, Coroutine, ...).
When implemented properly, you don't have to type them that
often anyway. I.e. you want to write t:append(e) instead
of Table.append(t,a) or x:sin() instead of Number.sin(x).