Hi HP

I already replied the "summary" email, but I think that here is an important question as well for your understanding

HP Wei wrote:
[...]
Now, the question is
in the original snippet,
when C = {NewCell S} is executed,
S is an unbound name,
how does the system decide whether S is
a variable,  a list or a list_with_future ??
 At which step in the snippet does the decision
  occur ?

The key concept is the variable, and you can bind it only once to a stream, a list, a number, an atom, a cell, etc. Once is bound, you can't change it. If you bind it to a cell, then, you can change the content of the cell. For instance you can do:

proc {Foo Type Var}
   if Type == cell then
      Var = {NewCell foo}
   elseif Type == stream then
      Var = 1|2|3|4|_
   else
      Var = foo
   end
end

So, the variable get its type dynamically.

cheers
Boriss

thanks
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

------------------------------------
At point A,  S contains  "1"|_
After point B,  S contains "1"|"2"|_

Hi HP


Here is the confusion. When you sent 1 to the port in point A, you took
the variable S out of the cell, bind it to 1|Mr and put Mr into the
cell, then, Mr is the unbound tail of S.
So, what you always keep in the
cell, is the current unbound tail of S. I hope I can do a nice drawing
of this.

S = |
   / \
  1   _ <---- C



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

Reply via email to