lua-users home
lua-l archive

Re: Adding custom bulit-in type

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


> 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

AltStyle によって変換されたページ (->オリジナル) /