[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: +=
- From: Edgar Toernig <froese@...>
- Date: Fri, 30 Mar 2001 22:11:43 +0200
Reuben Thomas wrote:
> ColorForth, I agree, is rather anorexic;
Hmm... my dictionary chokes on this one. But doesn't sound good
> although I do like the idea of colour tokens; it's sort of a Forth take on
> coloured syntax highlighting, and it does make sense in a curious sort of
But if the color makes syntactic and semantic differences?!? I'm not
sure of I should like that. IMHO it's just a matter of time until he
makes special glyphs for each word so that a complete program fits on
the display of a modular phone ;-)
Ok, enough about Forth.
> Lua 4.0, I must admit, has got to
> the stage where, apart from a few corners such as upvalues, it's difficult
> to see how the language could be further improved without damaging it.
> The obvious examples
> in Lua would be implementing OO and modules: both can be done pretty much
> without changing the language, but need a certain amount of discipline
> before they work properly.
That are two good examples. But contrary to you I think it would be
better to allow some changes to the language to make these features
good. Lua was not designed with these kind of things in mind. For
example the change to the global table was one step in that direction.
Yes, this is a minor change but it makes big differences. I could
imagine some more minor changes like this that would make OO-like
structures and modules as elegant as the rest of the language.
For example, I split objects in Sol. There's an object instance table
(the usual object table of Lua) that holds the instance data and the
object class table that holds class data (member functions, static
class data, etc.) It's called the method table in Sol. Multiple
objects may share the same class table. Access to the instance table
is via the dot (.) operator whereas access to the class table is
done via the colon (:) operator. That's all. A minor change but
big impact. 
Another thing I'm trying out is splitting the global table. Every
module gets a 'private' table. All global scope reads are first
done on the private table and global scope writes always write
into the private table . Ok, this can be done with standard Lua.
But the difference is, that _every_ function (C and Sol) gets the
currently active private table attached to it. When the function
executes, that attached private table is made the active one. That
way you basically get the 'static' storage class of C.  Another
small change which could make a difference. At the moment some
things still have to be worked out but I let you know if I have
something to show.
 That the class table also holds the tag methods for the objects
is another matter but it simplifies the language and its implementation.
 To write into the global table you have to use "global.name=xxx".
 As a side effect this makes _garbage collected_ dynamically loaded
binary modules (dl_open & co) pretty easy :-)