Hey, I'm very new to Mozart, and I have been having a problem trying to
create a function that uses a Memory Cell(Counter).  I'm getting an Error I
don't understand.  Here is the Code.

declare
fun{NewCounter}
   C Read Inc Init in
   C = {NewCell 0}
   fun {Inc N}
      C:=...@c+n
      @C
   end
   fun {Read}
      @C
   end
   fun {Init}
      C:=0
      @C
   end
   counter(inc:Inc read:Read init:Init)
end

declare
Sum={NewCounter}
Carry={NewCounter}

fun {AddDigits X Y}
   if (X + Y) == 2
   then
      {Sum.inc 1}
      {Carry.inc 1}
   end
end

{Browse {Sum.inc 1}}
{Browse {Sum.init}}
{Browse {Sum.read}}
{Browse {AddDigits 1 1}}

I have created two Counters that work as planned(basically pulled them out
of the book), and I want to access that memory cell/counter from another
Function in this case AddDigits.  If the sum of the numbers passed to the
funstion is X then I want to do Y to the memory cell.  in this case I just
made it 2 and I am passing 1 1 to the function.  But then I get this
error...


%*************** Error: illegal number of arguments *************
%**
%** In statement: {<P/2 Inc> 1}
%** Expected:     2 arguments
%** Found:        1 argument
%**
%** Call Stack:
%** procedure 'AddDigits' in file "c:/Documents and
Settings/Administrator/Desktop/oz.oz", line 22, column 0, PC = 18552396
%**--------------------------------------------------------------

Now I am looking at it and from what I can see this function doesn't see
this memory cell, because it is expecting two argements(Sum.inc and 1), but
it only sees the 1 which is why the {<P/2 Inc> 1} is there..  I'm just
curious as to why?  If I create the memory cell Do I need to pass it to the
function?  Should I not just be able to use it inside the function?


-- 
Kurt Breitsprecher
(807) 474-9601
[email protected]
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to