[REBOL] Re: initializing system/standard/email
From: tim-johnsons:web at: 3-Sep-2006 8:07
* jose <jjmmes-yahoo.es> [060903 05:37]:
> Hi Gabriele,
>
> I still don't see the bug and I've studied this code
> before.
>
> > > TJ> if not show [insert clear header-obj/to addr]
> > > TJ> ;; 'addr is being 'clear'ed
Hello jose:
> What is cleared is header-obj/to BUT not addr
1)'send needs the 'address and 'message arguments
2)with the /header refinement, a header-obj of type
object! is also required
The problem occurs when the /header refinement is used
and the 'to member of the header object is *also* used
as the 'address argument, because the following
block:
[insert clear header-obj/to addr] "destroys" the address
^ ;; same reference as 'address
Thus the fix is to create a new reference to the address
by using 'copy.
To better understand the issue here's a console session to
illustrate:
>> t: "jose"
t: "jose"
== "jose"
>> n: copy "jose"
n: copy "jose"
== "jose"
>> n = t
n = t
== true
>> same? n t
same? n t
== false
>> o: context [t1: "jose"]
o: context [t1: "jose"]
>> t2: o/t1
t2: o/t1
== "jose"
>> same? t2 o/t1
same? t2 o/t1
== true
>> clear t2
clear t2
== ""
>> probe o
probe o
make object! [
t1: ""
]
=====================================================
I hope this helps and by now you can see the 'copy
creates a new reference and when 'address and header-obj/to
are the same reference, changing one, changes the other.
tim ((whois an ol' "c-dog")
think-pointers!)
--
Tim Johnson <tim-johnsons-web.com>
http://www.alaska-internet-solutions.com