Multimethod dispatch function installation issues

2003-09-29 Thread Dan Sugalski
Okay, here's an issue for everyone. I'm writing the MMD subsystem, at least the parts needed for operator overloading, and I'm coming across the need to defer adding functions. For example, the Float class has functions for the Integer class, and vice versa, and we can't guarantee that both

Re: Multimethod dispatch function installation issues

2003-09-29 Thread Mark A. Biggar
Dan Sugalski wrote: Okay, here's an issue for everyone. I'm writing the MMD subsystem, at least the parts needed for operator overloading, and I'm coming across the need to defer adding functions. For example, the Float class has functions for the Integer class, and vice versa, and we can't

Re: Multimethod dispatch function installation issues

2003-09-29 Thread Dan Sugalski
On Mon, 29 Sep 2003, Mark A. Biggar wrote: Dan Sugalski wrote: Okay, here's an issue for everyone. I'm writing the MMD subsystem, at least the parts needed for operator overloading, and I'm coming across the need to defer adding functions. For example, the Float class has functions for

Re: Multimethod dispatch function installation issues

2003-09-29 Thread Nicholas Clark
On Mon, Sep 29, 2003 at 10:28:25AM -0400, Dan Sugalski wrote: On Mon, 29 Sep 2003, Mark A. Biggar wrote: Isn't there also the option to force load the missing class(es) recursively? We could, but I don't want to do that here. Just because a PMC class presents functions for other PMC

Re: Multimethod dispatch function installation issues

2003-09-29 Thread Nicholas Clark
On Mon, Sep 29, 2003 at 10:00:09AM -0400, Dan Sugalski wrote: So, I've two options: 1) When one or both of the classes a MMD function is installed for don't exist, we give them both class numbers (but don't load them) so when the classes *are* later loaded they already have numbers 2) We

Re: Multimethod dispatch?

2003-06-03 Thread Adam Turoff
On Sun, Jun 01, 2003 at 10:44:02PM -0600, Luke Palmer wrote: You must not be following Perl 6 closely enough, then. Perl 6 is a real programming language now, as opposed to a scripting language. Um, I've followed Perl6 closely enough to know that the distinction between real langauge and

Re: Multimethod dispatch?

2003-06-03 Thread Luke Palmer
Adam Turoff writes: On Sun, Jun 01, 2003 at 10:44:02PM -0600, Luke Palmer wrote: It will still have a lot of power in text processing, and still be a powerful quicky language, but that's no longer its primary focus -- not to say that highly structured programming is. Some applications

Re: Multimethod dispatch?

2003-06-03 Thread Graham Barr
On Mon, Jun 02, 2003 at 10:34:14AM -0600, Luke Palmer wrote: What it seems you're wanting is it to be in the core. And I'm saying that's irrelavent. There are thousands of great ideas out there, and they can't all fit into Perl's core. That's why there's thousands of modules on CPAN. Have

Re: Multimethod dispatch?

2003-06-03 Thread Adam Turoff
On Mon, Jun 02, 2003 at 10:34:14AM -0600, Luke Palmer wrote: And I don't see what's stopping someone from writing Dispatch::Value. use Dispatch::Value; sub foo($param is value('param1')) {...} sub foo($param is value('param2')) {...} What it seems you're wanting is it to be in

Re: Multimethod dispatch?

2003-06-03 Thread Me
A better fitting solution wouldn't focus on classic MMD, but simply Dispatch, where type- and value-based dispatching are two of many kinds of dispatching supported. I've always liked the sound of Linda's tuple spaces and view that as a nice generalized dispatch approach. Procedure calls are

Re: Multimethod dispatch?

2003-06-02 Thread Simon Cozens
[EMAIL PROTECTED] (Luke Palmer) writes: It will still have a lot of power in text processing, and still be a powerful quicky language, but that's no longer its primary focus -- not to say that highly structured programming is. So, uh, what is? And you can still do it the Perl 5 way in Perl

Multimethod dispatch?

2003-06-02 Thread Adam Turoff
Apologies if I've missed some earlier discussions on multimethods. The apocolypses, exegesises and synopses don't seem to say much other than (a) they will exist and (b) wait for apocolypse 12 for more information. Looking over RFC 256[*] and Class::Multimethods[**] it sounds like the intent is

Re: Multimethod dispatch?

2003-06-02 Thread Luke Palmer
Apologies if I've missed some earlier discussions on multimethods. The apocolypses, exegesises and synopses don't seem to say much other than (a) they will exist and (b) wait for apocolypse 12 for more information. Looking over RFC 256[*] and Class::Multimethods[**] it sounds like the

Re: Multimethod Dispatch

2002-09-05 Thread Dan Sugalski
At 9:27 PM -0400 9/4/02, Ken Fox wrote: Dan Sugalski wrote: At 9:10 AM -0400 9/4/02, [EMAIL PROTECTED] wrote: So, just to clarify, does that mean that multi-dispatch is (by definition) a run-time thing, and overloading is (by def) a compile time thing? No. They can be both compile time things or

Re: Multimethod Dispatch

2002-09-04 Thread [EMAIL PROTECTED]
From: Ken Fox [EMAIL PROTECTED] Over loading is what C++ has. It is not the same as multi-dispatch. The trouble with over loading is that the compiler uses static (compile-time) type information to select the over loaded method. This can create subtle bugs when people try to re-use code by

Re: Multimethod Dispatch

2002-09-04 Thread Dan Sugalski
At 9:10 AM -0400 9/4/02, [EMAIL PROTECTED] wrote: From: Ken Fox [EMAIL PROTECTED] Over loading is what C++ has. It is not the same as multi-dispatch. The trouble with over loading is that the compiler uses static (compile-time) type information to select the over loaded method. This can

Re: Multimethod Dispatch

2002-09-04 Thread David Wheeler
On Wednesday, September 4, 2002, at 06:58 AM, Dan Sugalski wrote: No. They can be both compile time things or runtime things, depending on the characteristics of the language. So if it's compile-time for a given language, how is it different from the Java concept of overloading? And will

Re: Multimethod Dispatch

2002-09-04 Thread Dan Sugalski
At 7:31 AM -0700 9/4/02, David Wheeler wrote: On Wednesday, September 4, 2002, at 06:58 AM, Dan Sugalski wrote: No. They can be both compile time things or runtime things, depending on the characteristics of the language. So if it's compile-time for a given language, how is it different from

Re: Multimethod Dispatch

2002-09-04 Thread Florian Haeglsperger
(), but that's the whole point of overloading and multimethod dispatch, isn't it? The usual list context / scalar context distinction would of course still be possible. It's just about _extending_ context sensivity. [Comments | Suggestions | Criticism] welcome.

Re: Multimethod Dispatch

2002-09-04 Thread Mark J. Reed
of the method). I believe this is what has been referred to as multimethod dispatch on this thread. An overridden method is two methods with the same name AND type signature in two different classes, where one class is a subclass of the other. The child class's method is said to override

Re: Multimethod Dispatch

2002-09-04 Thread Damian Conway
Dan Sugalski wrote: Dan, can you explain what multimethod dispatch is? Damian can explain it better than I can, I thought you did a great job! However, anyone who wants to know more about multiple dispatch might also like to read: http://www.samag.com/documents/s=1274/sam05010010

Re: Multimethod Dispatch

2002-09-04 Thread Ken Fox
Dan Sugalski wrote: At 9:10 AM -0400 9/4/02, [EMAIL PROTECTED] wrote: So, just to clarify, does that mean that multi-dispatch is (by definition) a run-time thing, and overloading is (by def) a compile time thing? No. They can be both compile time things or runtime things, depending on

Re: vtables and multimethod dispatch

2002-07-23 Thread steve
On Tue, Jul 16, 2002 at 03:35:30PM -0500, David M. Lloyd wrote: On Mon, 15 Jul 2002, John Porter wrote: There is really no inheritance of any kind going on, it just sticks pointers to the default functions into the vtable structure method entries for undefined methods. But that's

Re: vtables and multimethod dispatch

2002-07-16 Thread David M. Lloyd
On Mon, 15 Jul 2002, John Porter wrote: David M. Lloyd wrote: Do we really want *two* inheritance trees per object in Perl 6? One language-level and one PMC-level? Well, parrot != perl6, so I don't see a problem. Ugh. The MM dispatch problem is pretty much solidly in the realm of pmc

Re: vtables and multimethod dispatch

2002-07-16 Thread John Porter
David M. Lloyd wrote: John Porter wrote: The MM dispatch problem is pretty much solidly in the realm of pmc inheritance, There _is_ no pmc inheritance right now. There's just a set of default functions. Call it what you want. The point is that this type schema is at the parrot level,

Re: vtables and multimethod dispatch

2002-07-16 Thread John Porter
John Porter wrote: The point is that this type schema is at the parrot level, and is not the concern of a user-level language like perl Of course this is not really true; perl scalars, arrays, and hashes (etc.?) are implemented as PMCs under the hood, so in that sense they are related by

Re: vtables and multimethod dispatch

2002-07-16 Thread David M. Lloyd
On Tue, 16 Jul 2002, John Porter wrote: David M. Lloyd wrote: John Porter wrote: The MM dispatch problem is pretty much solidly in the realm of pmc inheritance, There _is_ no pmc inheritance right now. There's just a set of default functions. Call it what you want. The point is

Re: vtables and multimethod dispatch

2002-07-16 Thread John Porter
David M. Lloyd wrote: No, the point is that all this talk about type-space mm dispatch depends on there *being* type space. Since there is currently no inheritance to speak of then there really is no typespace so all of this talk is moot, I agree; but you did express a concern earlier that

Re: vtables and multimethod dispatch

2002-07-15 Thread David M. Lloyd
On Wed, 10 Jul 2002, Dan Sugalski wrote: What bothers me is this: the programmer needs to be able to predict what the machine is going to do with the code she gives it. And predicting how the machine is going to resolve the multimethod call could be, in any but trivial cases, far too

Re: vtables and multimethod dispatch

2002-07-15 Thread John Porter
David M. Lloyd wrote: Do we really want *two* inheritance trees per object in Perl 6? One language-level and one PMC-level? Well, parrot != perl6, so I don't see a problem. The MM dispatch problem is pretty much solidly in the realm of pmc inheritance, and that's something we have control

Re: vtables and multimethod dispatch

2002-07-12 Thread Ariel Scolnicov
--- Dave Mitchell [EMAIL PROTECTED] wrote: On Thu, Jul 11, 2002 at 01:18:51PM -0700, John Porter wrote: Nicholas Clark wrote: I was thinking that the metric (x*x + y*y) would be fast to calculate, as that's all we need for ordering. Point is, it's rather *more* than we need for

Re: vtables and multimethod dispatch

2002-07-12 Thread Dave Mitchell
On Thu, Jul 11, 2002 at 08:20:21PM -0700, John Porter wrote: Dave Mitchell wrote: IIRC, all metrics of the form (x^n + y^n)^(1/n), n=1,2,...Inf are strongly equivalent, ie they give rise to the *same* ordering. (In the limit as n - Inf, the metric is max(x,y).) I'm sorry, YDNRC.

RE: vtables and multimethod dispatch

2002-07-11 Thread John Porter
Brent Dax wrote: Nicholas Clark wrote: Unless I'm being thick, x² y² whenever x y for positive x and y (ie you don't need to take the square root of the hypotenuse to work out which hypotenuse is shorter. And all we're actually interested in which one is shorter, aren't we?)

Re: vtables and multimethod dispatch

2002-07-11 Thread John Porter
; the int isn't promoted to a float. Ah. In that case it's really a subset of multimethod dispatch, a subset of? It *is* multimethod dispatch, but for just a pre-defined subset of cases. Is that what you mean? If we can't find a match, or ... no clear winner, we throw an exception

RE: vtables and multimethod dispatch

2002-07-11 Thread Dan Sugalski
At 6:15 PM -0700 7/10/02, Brent Dax wrote: Nicholas Clark: # On Wed, Jul 10, 2002 at 10:17:47AM -0700, John Porter wrote: # # Dan Sugalski wrote: # # Heh. I never expected to have to dust off my trig skills when I # started this. If I need to dig out the calculus books, I # think I'll #

RE: vtables and multimethod dispatch

2002-07-11 Thread John Porter
Dan Sugalski wrote: Nicholas Clark: Unless I'm being thick, x y whenever x y for positive x and y (ie you don't need to take the square root of the hypotenuse to work out which hypotenuse is shorter. And all we're actually interested in which one is shorter, aren't we?) We can also

Re: vtables and multimethod dispatch

2002-07-11 Thread John Porter
Dan Sugalski wrote: That trades space for speed, Ain't it always the way. ! :-) In general that's potentially unbounded, but for the specific case of PMC vtable methods it's a fixed number. It gets more interesting for general methods and subs, but we can deal with that a bit later.

Re: vtables and multimethod dispatch

2002-07-11 Thread Andy Dougherty
On Wed, 10 Jul 2002, Nicholas Clark wrote: Dan Sugalski wrote: Heh. I never expected to have to dust off my trig skills when I started this. If I need to dig out the calculus books, I think I'll just go run screaming... Unless I'm being thick, x² y² whenever x y for positive

Re: vtables and multimethod dispatch

2002-07-11 Thread John Porter
Andy Dougherty wrote: Assuming x and y are coordinates in a 2-d space, and that both are integers = 0, why not just use what is affectionately called the taxicab metric: x+y? It is just as valid and even quicker to compute than the Euclidean metric sqrt(x^2 + y^2). Yes! Very incisive

Re: vtables and multimethod dispatch

2002-07-11 Thread Nicholas Clark
On Thu, Jul 11, 2002 at 10:52:31AM -0700, John Porter wrote: Dan Sugalski wrote: Nicholas Clark: Unless I'm being thick, x y whenever x y for positive x and y (ie you don't need to take the square root of the hypotenuse to work out which hypotenuse is shorter. And all we're

Re: vtables and multimethod dispatch

2002-07-11 Thread John Porter
Nicholas Clark wrote: I was thinking that the metric (x*x + y*y) would be fast to calculate, as that's all we need for ordering. Point is, it's rather *more* than we need for ordering. x + y will suffice. And I live in London, where we don't have a regular grid of streets, so our taxis

Re: vtables and multimethod dispatch

2002-07-11 Thread Dan Sugalski
At 8:58 PM +0100 7/11/02, Nicholas Clark wrote: On Thu, Jul 11, 2002 at 10:52:31AM -0700, John Porter wrote: Dan Sugalski wrote: Nicholas Clark: Unless I'm being thick, x y whenever x y for positive x and y (ie you don't need to take the square root of the hypotenuse to work

Re: vtables and multimethod dispatch

2002-07-11 Thread Dave Mitchell
On Thu, Jul 11, 2002 at 01:18:51PM -0700, John Porter wrote: Nicholas Clark wrote: I was thinking that the metric (x*x + y*y) would be fast to calculate, as that's all we need for ordering. Point is, it's rather *more* than we need for ordering. x + y will suffice. IIRC, all metrics of

Re: vtables and multimethod dispatch

2002-07-11 Thread John Porter
Dave Mitchell wrote: IIRC, all metrics of the form (x^n + y^n)^(1/n), n=1,2,...Inf are strongly equivalent, ie they give rise to the *same* ordering. (In the limit as n - Inf, the metric is max(x,y).) I'm sorry, YDNRC. Consider the distance from the origin to the points (0,6) and (3,4).

Re: vtables and multimethod dispatch

2002-07-10 Thread Dan Sugalski
a possibility, so we have to address it. As in the case of int-vs-float, maybe a kind of paper-scissors-rock rulebase that orders types. (What C/C++ hard-codes as type promotion.) Type promotion makes me more nervous than multimethod dispatch. I think I'd rather not do that unless we really have

Re: vtables and multimethod dispatch

2002-07-10 Thread John Porter
more nervous than multimethod dispatch. I think I'd rather not do that unless we really have to. But I'm not talking about actually doing type promotion; it's just a scheme to decide who gets to decide. In the example of int-vs-float, the rulebase (it's really just a DAG) decides that float wins

Re: vtables and multimethod dispatch

2002-07-10 Thread Nicholas Clark
On Wed, Jul 10, 2002 at 10:17:47AM -0700, John Porter wrote: Dan Sugalski wrote: Heh. I never expected to have to dust off my trig skills when I started this. If I need to dig out the calculus books, I think I'll just go run screaming... Not to worry. There's no trig involved.

Re: vtables and multimethod dispatch

2002-07-10 Thread Dan Sugalski
the arguments, and ask each one which they think ought to be the receiver? That would be O(n^2) in the number of args. Sort of. That's what the multimethod dispatch table does, though lookup is O(n) since we precompute the dispatch table. We look for the entry in the table based on the type of the left

RE: vtables and multimethod dispatch

2002-07-10 Thread Brent Dax
Nicholas Clark: # On Wed, Jul 10, 2002 at 10:17:47AM -0700, John Porter wrote: # # Dan Sugalski wrote: # # Heh. I never expected to have to dust off my trig skills when I # started this. If I need to dig out the calculus books, I # think I'll # just go run screaming... # # Not to

vtables and multimethod dispatch

2002-07-07 Thread Dan Sugalski
Okay, now that the dust from YAPC has settled and the holidays and such are done, it's time to get to some of the outstanding bits of Parrot. I'm going to get the extension mechanism designed over the next few days, but until then... We need a multimethod dispatch for vtable calls. Right now

Re: vtables and multimethod dispatch

2002-07-07 Thread Sean O'Rourke
On Sun, 7 Jul 2002, Dan Sugalski wrote: Basically what we need is a lookup matrix for each vtable method (add, subtract, multiply, whatever) that we can index by left and right types to get the actual method to call. I suppose resolution based on distance in number-of-args dimensional type

Re: vtables and multimethod dispatch

2002-07-07 Thread Dan Sugalski
At 2:08 PM -0700 7/7/02, Sean O'Rourke wrote: On Sun, 7 Jul 2002, Dan Sugalski wrote: Basically what we need is a lookup matrix for each vtable method (add, subtract, multiply, whatever) that we can index by left and right types to get the actual method to call. I suppose resolution based

Re: vtables and multimethod dispatch

2002-07-07 Thread Dan Sugalski
At 2:08 PM -0700 7/7/02, Sean O'Rourke wrote: On Sun, 7 Jul 2002, Dan Sugalski wrote: Basically what we need is a lookup matrix for each vtable method (add, subtract, multiply, whatever) that we can index by left and right types to get the actual method to call. I suppose resolution based

Re: vtables and multimethod dispatch

2002-07-07 Thread Mike Lambert
We need a multimethod dispatch for vtable calls. Right now we're working on a left side wins scheme and, while we're going to keep that (sort of) we really need a way to choose the method to call based on the types on both sides of binary operators. (Unary operators, luckily, are easier

Re: Multimethod dispatch for parrot?

2002-03-08 Thread Michel J Lambert
of macros for changing C strings, to Perl strings, to Unicode strings, and so on. This multimethod dispatch would make that work at the Parrot level, and just further the goal of inter-dynamic-language co-operation. In my opinion, this would provide several benefits over the current system. While (IMHO

Re: Multimethod dispatch for parrot?

2002-03-08 Thread Corwin Brust
corwin.dreamcafe.com */ - Original Message - From: Michel J Lambert [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, March 07, 2002 4:46 PM Subject: Re: Multimethod dispatch for parrot? Yes. We will, for actual method and sub dispatch. Not for the other vtable methods, though. I guess my

Re: Multimethod dispatch for parrot?

2002-03-08 Thread Ben Evans
On Thu, Mar 07, 2002 at 09:50:01PM +, Tim Bunce wrote: On Thu, Mar 07, 2002 at 01:48:49PM -0500, Dan Sugalski wrote: Someone said: First, there are basic native types such as num, int, and string, which I'm perfectly fine with. But what bothers me is the fact that bigint's and

Multimethod dispatch for parrot?

2002-03-07 Thread Michel J Lambert
Heya, I was curious if anyone has ever considered implementing multimethod dispatch (MMD) directly into parrot. In my opinion, this would provide several benefits over the current system. While (IMHO) MMD provides many benefits over the current system in terms of extensibility and ease

RE: Multimethod dispatch for parrot?

2002-03-07 Thread Brent Dax
Michel J Lambert: # I was curious if anyone has ever considered implementing multimethod # dispatch (MMD) directly into parrot. In my opinion, this would provide # several benefits over the current system. While (IMHO) MMD # provides many # benefits over the current system in terms

Re: Multimethod dispatch for parrot?

2002-03-07 Thread Tim Bunce
On Thu, Mar 07, 2002 at 01:48:49PM -0500, Dan Sugalski wrote: First, there are basic native types such as num, int, and string, which I'm perfectly fine with. But what bothers me is the fact that bigint's and bignum's are being given a special place in the vtable. Why? They're base

Re: Multimethod dispatch for parrot?

2002-03-07 Thread Shlomi Fish
With the possibility of making this thread off-topic: isn't multi-method a function that propogates according to the values of more than one argument? Like: sub myfunc { my ($a, $b) = @_; if ($a-isa('Vector3') $b-isa('Vector3')) { return