multiple arity method ov 
Author Message
 multiple arity method ov

        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

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

"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



-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



Subject: multiple arity method overloading
X-Relay-Info: Relayed through cs.bham.ac.uk NEWS->MAIL gateway



Thu, 25 Feb 1999 03:00:00 GMT  
 multiple arity method ov

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.

Quote:

>        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

>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

>"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



>-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



>Subject: multiple arity method overloading
>X-Relay-Info: Relayed through cs.bham.ac.uk NEWS->MAIL gateway

Suresh Kannan
Aerospace Engineering
University of Manchester

"Never wrestle a pig, you get dirty and it only irritates the pig"
                            - Leon the pig farmer


Fri, 26 Feb 1999 03:00:00 GMT  
 multiple arity method ov

        Reply to:
                   RE>multiple arity method overloading

I've never used C++. I don't think it has an open stack, so it doesn't face
the same problem. Dylan doesn't use an open-stack, but as I recall it
nevertheless has the same restriction. There might be something on the subject
in the Dylan Reference Manual  (available on the web somewhere).

The marker subterfuge may still encounter problems if other procedures might
leave a confounding marker lying around. It's hard to predict what might be on
an open stack.

I'll try to get back to you with more later.

Luc



Sat, 27 Feb 1999 03:00:00 GMT  
 multiple arity method ov

Suresh says:

| 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.

Because such a marker would have to be pushed on *all* procedure calls.
So far as the compiler is concerned, there is no difference between:

    smudge( 1, x, y );
    1, smudge( x, y );
    1, x, smudge( y );
    1, x, y, smudge();

Where and when would one push such a marker? The compiler (in general)
doesn't even know that smudge is a method that might need this action,
or an ordinary procedure that doesn't.

Also consider partial applications; if I construct smudge(% 42 %),
who's going to know to put in the marker when that gets called?

| I guess there will be a execution time penalty but the marker method
| could work.

Not, in general, in Pop.

| 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++.

C++ has static typing with all its disadvantages and advantages; the
compiler knows, for any method call, how many arguments its been given.
To do the same in Pop would require a rather powerful type system that would
(almost by definition) induce additional restrictions on the programs
you write.

Regards,    | ``"I can't suit myself," said Weinbaum, a little petulantly.
Kers.       | "I work for the Government".'' - Blish, "The Quincunx of Time".



Sat, 27 Feb 1999 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. multiple arity method overloading

2. Klass.method(:new).arity == -1 violates my POLS!

3. Method#arity problem

4. Method arity without instantiating an object

5. method arity from c

6. Arity of methods without having instance?

7. convert .LK and .OV to .DBF

8. Database with .ov, .lk files?

9. Whitespace, parentheses, methods, and arrays (was: Multiple file types in open dialog)

10. methods Accepting multiple data types

11. Efficiency in multiple inheritance attribute/method access

12. 1st-class method closures (was Re: Multiple return values)

 

 
Powered by phpBB® Forum Software