This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: KAWA - define-generic
Chris Bitmead wrote:
Hmm, I read the doco on make-procedure through about 5 times, but I'm
not sure I get it. The examples don't mention anything about types.
That's because overloading on types only works in some cases (such
as PrimProcedure objects). Overloading on number of arguments currently
works much better.
I assume you are saying that...
(define Plus (make-procedure
(lambda ((x :: <number>) (y :: <number>)) (+ x y))
(lambda ((x :: <string>) (y :: <string>)) (string-append x y))))
should work, but then below you are implying it won't.
Yes - the goal is that it should work, but it doesn't.
In any case, why must one specify all the methods up front? I thought
that kinda the whole point of generics was that you *don't* know up
front what all the possible options might be.
Well. modifying an existing procedure (which is what 'define-method'
would do) is very non-functional. It would be better to have a more
side-effect-free mechanism, and to use the module system to combine
methods. I've thought a little about it, but don't have a good
solution. The UW-Washington have one solution, I recall.
In any case, I will implement the mechanism to add methods to an
existing generic. But there isn't much point until generics themselves
are more useful.
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/