[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: On lua5 and embedding
- From: "jimmyp_gr <jimmyp@...>" <jimmyp@...>
- Date: Tue, 28 Jan 2003 23:30:43 -0000
--- In lua-l@yahoogroups.com, "Bilyk, Alex" <ABilyk@m...> wrote:
> Yeah, I was complaining about this as well. Then someone said that
__get and __set have been removed as a speed improvement. Curiously
enough, IMHO, one could actually do more with tags in Lua4 and it
would run faster as well. Meta-tables are slower and you'd want to get
rid of anything you can get away with while using them. In fact, in
current implementation of Lua5 Beta, it is partially optimized for
when one does NOT use meta-methods (Duh! What an important case for a
language whose main virtue is meta-table based extensibility).
Strange... To me tag methods and metamethods look a lot alike.Is the
table lookup to get the method what causes the slowdown.
> Basically, as long as one runs plain vanilla Lua5 scripts they will
go pretty fast. But as soon as one starts using inheritance, call and
other meta-methods on their objects that is when the meta-method
overhead jumps in. Syntax-wise meta-tables are pretty but with respect
to functionality they are impaired feature-wise as well as speed-wise,
in may view, compared to tags in Lua4 (boy, am I repeating myself or
what?). My only hopes are that meta-methods access will get optimized
at some point for a case when one actually uses them and that
computers are getting faster and faster allowing applications to
become a little more wasteful in terms of CPU and memory use and
letting programmers become less thoughtful at the same time.
I still don't get this.Can't some sort of caching system be
implemented.For example when settagmethod is called it can get the
values(or function pointers) of the defined metamethods and cache them
in an internal C table.Then the code to return the value of an
object(that is the __getindex or __get calls) could look like:
#define __GET somevalue
method=internal[__GET];
if(method==NULL)
return luavalue(...);
else
method(...);
Now that can't be so much slower than just:
return luavalue(..);
unless maybe inside a loop or something but then again lua is an
interpreted scripting language.