Re: __call and userdata
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: __call and userdata
- From: Graham Wakefield <lists@...>
- Date: 2007年3月15日 19:18:17 -0700
Ah, now I see what I missed. I wanted the semantics of noise = Noise
(), but I should then make Noise in Lua be the constructor function,
not the metatable.
Thanks
On Mar 15, 2007, at 7:03 PM, Rici Lake wrote:
Graham Wakefield wrote:
Hi all,
I'm having trouble using __call in a metatable for userdata; is
this supported?
Yes.
Here's a rough sketch:
print(Noise)
table.foreach(Noise, print)
noise = Noise()
Noise is a metatable. You create a userdata, setmetatable it to the
Noise table, and then call the userdata. (No need to expose Noise
to the Lua environment.)