% $Id: ArityError.oz,v 1.1 2007/11/27 02:52:32 leavens Exp leavens $ % This file is intended to demonstrate what % Mozart error messages "illegal arity in application" % and "wrong arity in application" mean. % It may be useful for you to feed it to Oz % and see what exact messages are generated, % so you can learn to read them. declare fun {Sum3 X Y Z} X + Y + Z end % Right, the two lines below are fine {Browse {Sum3 4 2 0}} _={Sum3 4 2 0} % The following 2 lines generate "illegal arity in application" {Sum3 4 2 0} % Arity error, using function as statement {Browse {Sum3 2 3}} % Arity error, not enough arguments proc {Add A B ?R} R=A+B end % Using Add as a 3 argument procedure (statement) is fine local R2 in {Add 3 4 R2} {Browse R2} end {Browse local R3 in {Add 3 4 R3} R3 end} {Browse {Add 3 4 $}} {Add 3 4 _} % Treating the procedure as a function that returns R is fine (sugar) {Browse {Add 3 4}} % The following line generates an "illegal arity in application" {Add 3 4} % Arity error, not enough arguments (used as statement) % The error below comes out becuase we used "fun" instaed of "proc" % which gives the message "wrong arity in application of Browse" fun {MeantToBeAProc X Y} {Browse X} {Browse Y} % Arity error, not returning a value from this function end