lua-users home
lua-l archive

Re: New user question re: settagmethod

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


> function inherit (object, field)
> if field == "parent" then -- avoid loops
> return nil
> end
> local p = object.parent -- access parent object
	I think you should use rawgettable instead:
	rawgettable (object, "parent")
> if type(p) == "table" then -- check if parent is a table
> return p[field] -- (this may call Inherit again)
> else
> return nil
> end
> end
> 
> -- Set the tag method.
> settagmethod(tag(BaseTable),"index",inherit)		 
	Here you can use just an empty table, but I think it'll be the same:
settagmethod (tag({}), "index", inherit)
	Tomas

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