[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Adding custom bulit-in type
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 27 Jul 2023 15:16:07 -0300
> it seems that I need to add an entry to the "Value" union in lobject.h,
Without memory allocation, that approach cannot work because the
fields correspond to *values*, not objects, and so "foo.x = 3" can
never affect the value of "foo". Note that this is true even when
"foo" contains a table: "foo.x = 3" changes to contents of the table
but not the contents of "foo".
With memory allocation, you'll be well served by ordinary tables,
without patching Lua:
function vec2(x,y)
return {x=x,y=y}
end