[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Sep 9 12:48:41 1996 
Subject:Re: multiple arity method overloading 
From:Suresh Kannan 
Volume-ID:960909.02 

Yes I realize that could be a problem.  I am no expert on compiler or
interpreter design, but why not push a 'marker' on to the stack so
that items are read from the stack until the marker is reached.  I
guess there will be a execution time penalty but the marker method
could work.  In that case the limitation on the final argument
deciding which method is executed is withdrawn.  Thus one has more
flexibility and it is the "typed" arguments that matter.  

I must admit I have programmed in C++ which allows this.  I wonder how
it is done in c++.

regards,
suresh.


luc_beaudoin@qmail.newbridge.com (Luc Beaudoin) wrote:

>        Reply to:
>                   RE>multiple arity method overloading 

>I haven't used Pop in a long time, but there is a problem in implementing what
>you want:  it is impossible (without kludges) to get dispatching to work
>properly. E.g., you define two methods with these headers (I've forgotten the
>syntax):

>define method aMethod ( anApple: Apple, aBanana: Banana);
>enddefine;

>define method aMethod (aBanana :Banana);
>enddefine;
>which method is dispatched when you apply -aMethod- to aBanana? There might be
>anApple on the stack right after aBanana.

>Luc

>--------------------------------------
>Date: 9/8/96 2:43 PM
>To: Luc Beaudoin
>From: suresh@roja.demon.co.uk
>Hello,

>I am not on pop-forum, hence any replies on comp.lang.pop appreciated

>The new objectclass library in poplog 15.0 is an excellent
>development.  But there is one serious limitation.  Although
>procedures can be have different *types* of arguments it is not
>possible to have varying *number* of arguments for a given procedure
>name

>eg 2D geometry

>define translate(pt:point,dx,dy)
>....
>enddefine;

>define translate(pt:point,refpt:point,dx,dy)
>...
>enddefine;

>In the second case i wish to supply one more argument but this is
>illegal in pop11.  The arity of the methods will depend on which
>method is compiled first.

>I have resorted to the rather inelegnt 'printf' way of handling
>multiple arguments where I send the arguments in a list and I use a
>procedure to determine the argument types and finally apply the
>correct procedure.

>sample procedure call :-
>---------------------------------
>translate(pt,[^dx ^dy]);
>translate(pt,[^refpt ^dx ^dy]);


>underlying code :-
>-------------------------
>define translate(obj,arglist);		/* handling function */
>   examine arguments
>   decide on procedure to apply
>   apply appropriate method
>enddefine;

>point_translate1(pt:point,dx,dy);
>point_translate2(pt:point,refpt:point,dx,dy);
>segment_translate1(pt:point,dx,dy);
>segment_translate(pt:point,refpt:point,dx,dy);

>This messy implementation can be avoided if poplog's objectclass
>allowed methods to have a varying number of arguments.  I guess this
>is related to the compiler deciding how many items to read off the
>stack but I am sure this can be overcome..

>This is a suggestion and hope it will be taken up.

>regards,
>suresh.

>Suresh Kannan
>Aerospace Engineering
>University of Manchester
>suresh@roja.demon.co.uk
>"Never wrestle a pig, you get dirty and it only irritates the pig"
>                            - Leon the pig farmer


>------------------ RFC822 Header Follows ------------------
>Received: by qmail.ca.newbridge.com with ADMIN;8 Sep 1996 14:34:41 -0500
>Received: from wwwnni.us.newbridge.com (herngate [138.120.108.177]) by
>hernmaster.us.newbridge.com (8.6.12/8.6.12) with ESMTP id OAA03193 for
><luc_beaudoin@qmail.ca.newbridge.com>; Sun, 8 Sep 1996 14:29:23 -0400
>Received: (from adm@localhost) by wwwnni.us.newbridge.com (8.6.12/8.6.12) id
>OAA07959 for <luc_beaudoin@qmail.newbridge.com>; Sun, 8 Sep 1996 14:38:18
>-0400
>Received: from unknown(15.255.59.2) by wwwnni via smap (V1.3)
>	id sma007956; Sun Sep  8 14:38:03 1996
>Received: from otter.hpl.hp.com by hplb.hpl.hp.com; Sun, 8 Sep 1996 19:32:59
>+0100
>Received: from hplb.hpl.hp.com by otter.hpl.hp.com with ESMTP
>	(1.37.109.16/15.6+ISC) id AA021397553; Sun, 8 Sep 1996 19:32:33 +0100
>Received: from frank.cs.bham.ac.uk by hplb.hpl.hp.com; Sun, 8 Sep 1996
>19:32:32 +0100
>Received: from percy.cs.bham.ac.uk (actually host percy) 
>          by frank.cs.bham.ac.uk with SMTP (MMTA);
>          Sun, 8 Sep 1996 19:32:14 +0100
>Received: by percy.cs.bham.ac.uk (4.1/client/1.2)        id AA15789;
>          Sun, 8 Sep 96 19:32:10 BST
>Date: Sun, 8 Sep 96 19:32:10 BST
>Message-Id: <15789.9609081832@percy.cs.bham.ac.uk>
>To: pop-forum@cs.bham.ac.uk
>From: suresh@roja.demon.co.uk
>Subject: multiple arity method overloading 
>X-Relay-Info: Relayed through cs.bham.ac.uk NEWS->MAIL gateway




Suresh Kannan
Aerospace Engineering
University of Manchester
suresh@roja.demon.co.uk
"Never wrestle a pig, you get dirty and it only irritates the pig"
                            - Leon the pig farmer