lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 04/20/2014 08:55 PM, Dirk Laurie wrote:
2014-04-20 13:50 GMT+02:00 Peng Zhicheng <pengzhicheng1986@gmail.com>:

I feel it too much overhead using the full userdata just to pass some opaque
values, and I need to set a per-instance metatable everytime I produced that
value.
Given that you will have a metatable per instance, please explain (more
concisely than the original post please) just how much overhead relative
to a full userdata you think you are saving.


sorry if my original post is misleading, English is not my native language, anyyway

I provide the patches simply because I think it is a interesting idea, not as any kind
of proposals. I am using only the smaller patch right now.


in fact I am not encountering performance probelms right now. I just don't _feel like_
the way I currently do it. I'm sometimes sqeamish and paranoid. but, you know, using
a patched verson of Lua also makes me uncomfortable. sadly.

as I said, I realized my current predicant is due to the design flaw: I added more
functionality to the library, but re-used the existing scripting interface. I have to
dispatch the call based on the _type_ of some parameter, which are just opaque values
pushed to the Lua scripts. without the varbits patch, I used full userdata to store
this opaque values and used metatables to indicate the types of the values.

(BTW, two alternate methods I had played with: using the lowest bits of the opaque
value -- algined pointers actually -- as some type tag, and delegating the dispatching
to the polymorphism of C++: what I called the Lisp way and the COM way.)

I am planning to redesign the scripting API, so I could get away the dispatching.
yet that means I have to rewrite a bunch of Lua scripts, which takes a long time.
so the patch is indeed a temperary work during this transition time.


anyhow, the patches SHOULD be useless for most people I suppose.