lua-users home
lua-l archive

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


What do you exactly mean by "nested userdata" - can you give some easy
to understand example?

... e g. you want to create an "assembly of 100 rectangles", and you
want to avoid Lua to create 100 userdata elements for you?

I this case I would recommend that you create some special userdata,
which is e. g. called "userdata.shapfield" with some "new" function,
and then you can create this with shapefield.new(100, 'r') ('r' for
rectangle) ... this then will be given to your C new function and C
will then have to ask for the necessary data amount from Lua for this
"pool of 100 rects" ... .

This should run quite similar to the "bitarray" example described
nicely in Roberto's "Programming in Lua"... .

On Wed, Nov 10, 2021 at 12:06 PM Patrick Kurth <p.kurth@posteo.de> wrote:
>
> On Wed, 2021-11-10 at 11:56 +0100, Flyer31 Test wrote:
> > But combining your question with performance issues from the beginning
> > is also I think too hard for a "start point"... better start first
> > with simple examples (but the task must be very clear then..), then
> > get this working, and then try to optimize this further if you
> > want/can/do ... (but do not forget Roberto's two very smart base rules
> > in from the Lua Gem's book concerning optimization: Rule no. 1: Don't
> > do it, and Rule No. 2: Still don't do it :) ).
>
> Apparently I was not clear enough :) I already have a well working
> system/application [1], where I want to improve performance and add
> some functionality in C. So this is not a planning problem at the
> beginning of something, I'm already in the middle of it.
>
> [1] https://github.com/patrickschulz/openPCells