Removing members from a context
[1/3] from: GedB:Rushcoding at: 30-May-2007 11:08
Hi, I'm just getting to grips with contexts and the like, and I have a quick question. Given a context, like t: context [a:1 b:2 c:3], is it possible to remove one of the members. For example removing b so that t is [a:1 c: 3]? Thanks, Ged.
[2/3] from: anton::wilddsl::net::au at: 30-May-2007 21:35
The answer is no. You can't add or remove members from an object. Once created, the members are fixed. The only thing you can do is derive a new object from the old one, specifying only the members you want to keep, and then copy the values across from the old object. eg. old: context [a: 1 b: 2 c: 3] members: exclude first old [self c] ;== [a b] spec: copy members forall spec [spec/1: to-set-word spec/1] append spec none ;== [a: b: none] new: context spec foreach word members [set/any in new word get/any in old word] print mold new ;== make object! [a: 1 b: 2] In Rebol version 3, the above situation changes a little bit, and you will be allowed to add members to an existing object. However, I don't think that you will be able to remove members. Regards, Anton.
[3/3] from: GedB::Rushcoding::co::uk at: 30-May-2007 15:21
Thanks Anton. On 5/30/07, Anton Rolls <anton-wilddsl.net.au> wrote: