lua-users home
lua-l archive

Re: Translating from a VERY "loose" language

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


--- PA <petite.abeille@gmail.com> wrote:
> 
> On Jun 11, 2007, at 19:22, Timon Christl wrote:
> 
> > Note that the manual says the metatable for
> > non-table values can only be changed in C code.
> 
> Or through the debug module:
> 
> debug.setmetatable( nil, { __index = function( self,
> aKey ) return aKey 
> end } )
> 
> print( ( nil ).dwim )
> 
> > dwim
Thanks for the example. But what is the syntax for
setting the metatable for numbers? I tried this:
debug.setmetatable( number,
	 { __eq = function( a, b )
	 	 return a <= b and b <= a
	 	 end
	 }
)
print( 3 == 4 )
but __eq doesn't seem to be called.

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