[REBOL] Re: Embedded objects - deviation
From: lmecir::mbox::vol::cz at: 14-Mar-2003 9:22
Hi James,
to keep IT simple, I changed the wording a bit. Any experiments and experiences are welcome:
dynamic: function [
{make a dynamic object}
spec [block!]
/inherit object [object!]
] [result] [
result: make object! [!: none]
result/!: make either inherit [object/!] [object!] spec
result
]
; this is how you can create dynamic objects:
Bob: dynamic [name: "Bob"]
BobsDog: dynamic [name: "Rex"]
SuzyCat: dynamic [name: "Suzy"]
; this is how you can query dynamic objects:
Bob/!/name ; == "Bob"
BobsDog/!/name ; == "Rex"
SuzyCat/!/name ; == "Suzy"
; this is how to add properties to a dynamic object:
Bob/!: make Bob/! [Dog: BobsDog]
BobsDog/!: make BobsDog/! [Cat: SuzyCat]
Bob/!/Dog/!/name ; == "Rex"
BobsDog/!/Cat/!/name ; == "Suzy"
Bob/!/Dog/!/Cat/!/name ; == "Suzy"
; inheritance:
Andy: dynamic/inherit [name: "Andy"] Bob
Andy/!/Dog/!/name ; == "Rex"
Regards
-L