After reading Boriss's detailed info and
Paolo, Andreas and Max's comments,
I realized that the way I understood it in
the earlier emails today was not quite clear.
This email should clarify the gray area in my
understandings. I hope I finally got it right :)
-------------------------------
It all boils down to understanding the difference
in the following two snippets.
local S C Ms Mr in
C = {NewCell S}
{Exchange C Ms Mr}
Mr = xyz
{Browse S}
{Browse @C}
end % output: _ "xyz"
local S C Ms Mr in
C = {NewCell S}
{Exchange C Ms Mr}
Ms = xyz
{Browse S}
{Browse @C}
end % output: "xyz" _
--------------------------------
The concept of variables being bound only once is
not usual for long-time imperative programmers such as
myself.
In any case, after I undertood the difference in the
above, the following is the summary of what is going on
in the code in the original post -- appended at the end of this email.
I extracted the essential part in the following snippet.
local S C Ms Mr in
C = {NewCell S}
{Exchange C Ms Mr} % point A
Ms = a|Mr % point B
{Browse S}
{Browse @C}
end % output: "a"|_ _
At point A, the snapshot of names is as follows:
S is unbound
C contains the content of S(unbound) -- before the Exchange.
Ms contains the content of C = content of S(unbound)
Mr is unbound.
the Exchange further copies the contents of Mr into C
-- C becomes Mr(unbound)
[ NOTE this is crucial because Mr(unbound) later
becomes the tail of S !]
At point B,
M = a
Mr is still unbound
Ms = S = a|Mr
i.e. the stream S becomes "a"|_
and C contains (Mr(unbound)) -- the tail of S.
It all works out!
-----------------------------------------------------
Thanks
HP
On Sun, 11 Dec 2005, HP Wei wrote:
> I hit a metal block when trying to understand
> Figure 9.3 in chapter 9 in the Tutorial of Oz on the mozart web site.
>
> Here is the snippet that I copied from Figure 9.3 (with irrelevant part
> deleted).
>
> 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