Eduardo Cavazos
2004-07-05 23:46:55 UTC
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
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