HP Wei wrote:
Ignore my previous email this morning!
I re-read Boriss and Paolo's  reply one more time
and finally it dawns on me :)

I see it now!  For confirmation and for the benefit of other newbies,
let me re-iterate what I understand from those two
emails.  [ correct me if I am wrong. ]

---------------------------------------

The point that I missed was that
the cell C *points* to an unbound variable
(denoted as old_ub).
And it remains so forever :)

becareful, it remains like that, because the algorithm is doing so. Look

proc {Send P M}
   Ms Mr
in
   {Exchange P.Tag Ms Mr}
   Ms = M|Mr
end

P.Tag is the Cell. Ms and Mr are unbound variable. With the exchange function you are updating the value of the cell with an unbound variable, which later is going to become the new tail of the stream (when you say Ms = M|Mr).

[  In analogy to C languange, cell C is a pointer. ]

you could see it like that (some Oz purist will surely complain). But the idea is that is a box which contain can change. Thus, the cell is a statefull entity. Variables can not change their value once they are bound.


No matter where we start (point A or point B),
at point C,
Ms is first assigned with the *content* of C
which is the unbound (old_ub),
and Mr is another unbound name (denoted as new_ub).

Becareful with the concept of Names in Oz. They have their own semantics. Consider Ms and Mr as variables.

Next, Exchange swaps the above two.
Ms becomes new_ub,  Mr old_ub.

So, Ms = M|Mr simply binds new-ub
with  M|old_ub.  Effectively, S is being
appened by M|old_ub.
At this moment, C is still pointed to old_ub.

right

--hp





On Mon, 12 Dec 2005, Boriss Mejias wrote:


declare P S in
local
 Tag = {NewName}
 fun {NewPort S}
    C = {NewCell S} in
    {NewChunk port(Tag:C)}
 end
 proc {Send P M}
    Ms Mr in
    {Exchange P.Tag Ms Mr}
    %%% point C
    Ms = M|Mr  %%% point D
 end
in
 P = {NewPort S}
 {Send P 1} %%% point A
 {Send P 2} %%% point B
end




_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to