Charles napsal(a):
> Here's a little question. Suppose I do something like
>msg: make system/standard/email []
>probe msg
>make object! [
> To: none
> CC: none
> BCC: none
> From: none
> Reply-To: none
> Date: none
> Subject: none
> Return-Path: none
> Organization: none
> Message-Id: none
> Comment: none
> X-REBOL: "1.2.1.3.1 http://WWW.REBOL.COM"
> MIME-Version: none
> Content-Type: none
> Content: none
>]
>
>Suppose I wish to remove a field, like Comment or X-REBOL. How would I do
>that? Can I ... delete a field, make it no longer a part of the object?
>
>
you cannot remove a field (I call it attribute) from an existing object,
but you can create a new object having only the attributes you really
need e.g. as follows:
o: make object! [a: 1 b: 2 c: 3]
o: exclude-attributes o [a b]
the EXCLUDE-ATTRIBUTES function is an "easy exercise for the reader" :-)
-Ladislav
P.S. here is my homework:
exclude-attributes: func [
{exclude some attributes}
original [object!] {the original object}
attributes [block!] {attributes to exclude}
/local new-spec to-set result
] [
; exclude the 'spec word
new-spec: exclude first original [self]
; exclude other attributes
new-spec: exclude new-spec attributes
; remember attributes that need to be set
to-set: copy new-spec
repeat i length? new-spec [poke new-spec i to set-word! new-spec/:i]
insert tail new-spec none
; create an empty new object
result: make object! new-spec
; set the attributes in result
foreach attribute to-set [type? set/any bind attribute in result
'self get/any bind attribute in original 'self]
; make sure to obtain copies where appropriate
make result []
]
--
To unsubscribe from the list, just send an email to rebol-request
at rebol.com with unsubscribe as the subject.