lua-users home
lua-l archive

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


It was thus said that the Great Roberto Ierusalimschy once stated:
> > 	  __newindex = function(self,k,v)
> > 	    if k == 'x' then
> > 	      -- magic  code to set x portion of self to v
> > 	    elseif k == 'y' then
> > 	      -- magic code to set y portion of self to v
> > 	    end
> > 	  end
> > 	}
> > 	
> >   What am I missing?
> 
> Whatever you do, __newindex receives a copy of the original 'v', not
> the original. If 'v' is/has a pointer (created with allocation), then
> the copy and the original point to the same memory, and changing that
> memory affects both 'v' and the original value. If 'v' does not
> is/has a pointer, then changing it cannot affect the original value
> that 'v' is a copy.

  I take it there's no easy way to get to the underlying TValue *?

  -spc