Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Dynamically Modifying objects!

From: edanaii:cox at: 22-Feb-2003 7:34

Joel Neely wrote:
>Hi, Ed, > >Your approach doesn't dynamically modify an object. It packages >up a way to create a *new* object based on modifying the previous >one. To see that this is true, consider this transcript: >
Yes, I know. I never said otherwise. I merely stated that this was my solution to the "problem". For all intents and purposes, the object is dynamic. Maybe not in the truest sense of the word, but certainly enough to achieve my goals.
>Thus far I followed your example, but let's add one new step here: > > >> customer: contact > >so that we now have another reference to the original CONTACT >object via a different word. Now continuing with the exploration: > > >> contact: contact/_add [address: "32 E. Deer Trail"] > >> contact/_data > == [name address] > >> contact/address > == "32 E. Deer Trail" > >However, we didn't *modify* the object referenced by CONTACT; we >just made a new object and set CONTACT to that new object. If we >use the other reference, we see that fact, because the ADDRESS >attribute is only in the *new* object, not added to the original: > > >> customer/_data > == [name] > >> customer/address > ** Script Error: Invalid path value: address > ** Where: halt-view > ** Near: customer/address >
This was never my intention. I didn't want attributes shared between parent and child dynamically. I wanted the ability to add and remove attributes from the currently instantiated object. And my approach was to model it as closely as possible to how REBOL normally does it.
>The only way to get shared mutations that I can think of right now >would be something like the following, which explicitly manages >the sharing: >
[Snip, example of dynamic inheritance]
>after which the original reference (to the wrapper) also allows >access to the modified sub-object: > > >> contact/data > == [name address wife] > >> contact/shared/wife > == "Betty" >
Very nice. :)
>Hmmmmmm... I probably should have called SHARED something else, if >the enclosed object is going to have a WIFE attribute!! ;-) >
Maybe you should have named it Swinger/Shared/Wife. =) -- Sincerely, | Ed Dana | Faith is believing what you know ain't so. Software Developer | -- Mark Twain 1Ghz Athlon Amiga |