[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: "namespaces" ?
- From: Edgar Toernig <froese@...>
- Date: Mon, 22 Apr 2002 18:01:42 +0200
Roberto Ierusalimschy wrote:
> Just to remind you, Lua 4.0 already had support for this kind of OO
> programming with basic types. For instance,
> settagmethod(tag(""), "gettable", function (a,b)
> return getglobal('str'..b)
> > ansiStr = "Hello"
> > print(ansiStr:lower())
That may look the same but it's quite different. Not only that you
don't have to use tag methods (and the performance hit that takes),
try to simulate for example this in _addition_ to your code above:
String.gettable = String.substr -- 
print("abc") --> c
is the same as
That aside, since the introduction of the 'metatables' your example
is no longer allowed. The only metatable a Lua app has access to is
that of tables.