[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: upvalues and polymorphism
- From: lhf (Luiz Henrique de Figueiredo)
- Date: Fri, 15 May 1998 15:41:47 -0300
>From firstname.lastname@example.org Fri May 15 15:30:25 1998
>I think the bigger question to ask is why table operations and tag methods
>are different. Namely, why isn't syntax execution defined as a table
>access, and thus all values would be tables.
>For example, "foo(1,2,3)" would trigger the evaluator:
>whereas "foo" would trigger the evaluator:
>and "foo = bar" would trigger the evaluator:
This is almost exactly what Lua does right now.
You can set tag methods to catch all these.
They are called "function", "gettable", "setglobal", ...
>Perhaps this isn't a good idea, or dosn't buy us much. However, if the
>idea were to unify everything under some concept, I would far sooner think
>the general concept of tables would unify everything, than the
The rationale is that whenever you want to do something special, put a
table around the objects you want to handle and set tag methods to catch
the operations done to the objects.
This is what a "meta-mechanism" is all about.
>If I was going to add something to Lua, I'd spend my time trying to do
>some sort of table lookup cache, as currently using multiple levels of
>tables for orginization (either as classes, or just as heirarchy) costs.
Really? Table lookup should take constant time.
Do you have hard data on performance costs? We'd be interested...
>In fact, for this specific reason, I'd like to see the "lookup" VM codes
>dereference a complete table lookup, instead of just one slot. It would be
>much more efficient to come up with a cache method for:
>than it is to optimize:
That would be something like "with" in Pascal.
Right, this would be slightly more efficient, but like I said, table lookup
should take constant time. So we're tlking about .1 msec vs .3 msec :-)
This is a reasonable suggestion but would require adding a "with" construct.
>Am I wrong in assuming that table lookup is somewhat costly in lua?
Yes. Table lookup should take constant time because it's based on hashing.
What costs did you have in mind?