[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Dec 15 18:51:16 2002 
Subject:Re: newbie: help with ARITY error 
From:Aaron Sloman 
Volume-ID:1021215.01 


ggroups@zapataz.co.uk (Paul Humphreys) writes:

> Date: 15 Dec 2002 06:56:51 -0800
> Organization: http://groups.google.com/
>
> Keep getting this error...
>
> ;;; MISHAP - ocmpa: ARITY OF METHOD PARTS DO NOT AGREE
> ;;; INVOLVING:  <procedure north>
> ;;; FILE     :  /home/paul/oo.p   LINE NUMBER:  59
> ;;; DOING    :  Check_arity update_method method_form define_method
> define
> ;;;     runproc
>
> Receive the error message whenever i change the parameters of a
> method, which i would like to do a lot at the moment as I'm trying to
> learn about objects etc.

If you change the arity of an Objectclass method by adding or removing
parameters you'll have to alter ALL occurrences of the method in exising
code so that they are consistent with the new set of parameters.

You'll also need to cancel the old method identifier.

Example:

define :class silly;
    slot val == 0;
enddefine;

define :instance fred:silly;
enddefine;

fred =>
** <silly val:0>

define :method alterval(x:silly, y);
    y + val(x) -> val(x);
enddefine;

alterval(fred, 33);

fred =>

define :method alterval(x:silly, y, z);
    y + z*val(x) -> val(x);
enddefine;

;;; MISHAP - ocmpa: ARITY OF METHOD PARTS DO NOT AGREE
;;; INVOLVING:  <procedure alterval>
;;; .....etc.....

;;; Now cancel the method name (this removes any syntactic
;;; information previously associated with the word -- it's
;;; almost as if you had removed it from Pop-11's dictionary so that
;;; it will not be recognized thereafter.

cancel alterval;

;;; you can now define the new method

define :method alterval(x:silly, y, z);
    y + z*val(x) -> val(x);
enddefine;


alterval(fred, 33, 4);

fred =>
** <silly val:165>

See HELP CANCEL
It points to some other relevant things. Gory details are in
REF IDENT and REF SECTIONS, REF WORDS

There's more information in HELP IDENTIFIERS

If you cancel an identifier and then redefine it, that will not affect
procedures already compiled using the identifier as it was before
cancellation. They will continue to access the old identifier.
So you need the following steps:

1. cancel identifier

2. redefine method

3. recompile all methods procedures using the method before
   it was cancelled.

> Can not find anything about this in the teach files, seems as if the
> method signature  is getting cashed somewhere. The only workaround i
> have is to change the method name whenever i want to change the
> parameters.
>
> Is there an easier workaround, some setting I've not enabled or am
> being dumb and forgot something fundamental?

The mechanisms in Pop-11 involving words, identifiers, sections, values
of variables, are quite complex.

We need a better tutorial file than HELP CANCEL. I can't recall whether
it is explained better in any of the printed text books. Probably not.

Of course, if you exit from Pop-11 and start again, that's equivalent to
cancelling everything you've defined so far.

Aaron
====
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk   (ReadATas@please !)
PAPERS: http://www.cs.bham.ac.uk/research/cogaff/ (And free book on Philosophy of AI)
FREE TOOLS: http://www.cs.bham.ac.uk/research/poplog/freepoplog.html