Re: Allowing incongruent methods
Jonathan Bachrach <[email protected]> Tue, 20 Jul 2004 12:42:49 -0400
| Newsgroups | gmane.comp.lang.goo.general |
|---|---|
| Message-ID | <[email protected]> |
we never implemented this in goo. it would be nice. it would probably be important to add a mechanism to generic function definition to allow the specification of at least the possibility of optional parameters. then there's the question of how to address keyword parameters esp wrt to method selection. in the end we took the conservative route. jonathan On Jul 5, 2004, at 7:46 PM, Eduardo Cavazos wrote: > Hello Goons, > > Here's an example of something I'd like to do in a CLOS like language, > but > haven't been able to. I'm wondering; does any language out there allow > this? > From the GOO manual, I've gathered that GOO may eventually allow this. > Also, > since this sort of thing is not yet possible, is there some sort of > deep reason > for languages not implementing this capability? > > Let's say I want a method called 'range' that yields a list of numbers > from 'a' > to 'b' by step 's'. The general form of the method is: > > (define-method range (a b s) > (if (> a b) > '() > (cons a (range (+ a s) b s)))) > > Now I also want a couple of other range methods. One where only 'a' > and 'b' are > given and 's' is assumed to be 1. And the case where only 'b' is > given, so 'a' > is assumed to be 0 and 's' is assumed to be '1': > > (define-method range (a b) > (range a b 1)) > > (define-method range (b) > (range 0 b)) > > When I try this in CLOS, Goo, or RScheme, I receive an error. > > This is just a simple example to illustrate the idea. > > Section 19 of the Goo manual mentions that Goo will in the future > allow for > differing numbers of required parameters, so I guess that means that > something > like the above will eventually work in Goo. > > Thanks for any comments or pointers, > > Ed