|
how do you implement the __write metamethod for tables? are you create a proxy table? For userdata, the __newindex metamethod is always called, but for tables, the __newindex metamethod is only called when the key isn't exist in the table. > Date: Tue, 28 Aug 2007 14:58:16 -0700 > From: steve@steveheller.com > Subject: __write method? > To: lua@bazar2.conectiva.com.br > > > --- Mark Hamburg <mhamburg@adobe.com> wrote (on Fri, > 05 Sep 2003): > > "For some structures, it is really useful to have a > write metamethod that is > always called rather than only being called when the > index isn't present. > Userdata already provides this, but tables don't. So, > I set out to implement > one for tables. My intended semantics were that if a > table had a __write > metamethod, this would be called for any non-raw set > operations performed on > the table. > > I would change userdata to do the same thing, but that > would break existing > semantics if I replaced __newindex with __write and > adds extra overhead if I > test for both." > > I need som ething very much like this. Would your > implementation work in Lua 5.1? If not, would you be > able to provide a version that would? I'm not > conversant with the Lua C code, or I'd do it myself. > > Thanks! > > 使用新一代 Windows Live Messenger 轻松交流和共享! 立即体验! |