lua-users home
lua-l archive

Re: Deep Copy prototype

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


Ben,
>is there really a need to deep-copy strings, given that
>they're immutable?
What if I create an object prototype, clone (deep-copy) it, then change a string "property" in the new object-table. I don't want it to change the string in the prototype.
Trite Example:
prototypeDoc = { name="", author="Brad"}
Doc1 = clone( prototypeDoc}
Doc1.name = "Why Trees Fall"
Doc1.author = "Gumby Jr." --Does this assignment also affect prototypeDoc.author?
--Now I want to be able to assert this:
assert( prototypeDoc.author ~= Doc1.author)
Maybe I'm not thinking in Lua clearly here. I'm not in love with objects: I just want to say, here's a prototype of a structure. Clone it, change a few things, make it work as you want.
--Brad Olson
--executive@att.net 
--05/07/2003 at 1:52:31 PM

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