This is the mail archive of the
mailing list for the Kawa project.
- To: kawa at sources dot redhat dot com
- Subject: generic procedures
- From: Matthias Radestock <matthias at lshift dot net>
- Date: Wed, 01 Nov 2000 09:30:31 +0000
Isn't the following supposed to work ?
(define f (make-procedure (lambda ((x :: <int>)) x)
(lambda ((x :: <string>)) x)))
(f 10) ;=> should return 10
(f "foo") ;=> should return "foo"
Instead of the expected results I get:
Argument to `null' has wrong type
This is using the latest version of kawa from CVS.
Looking at the code, it appears that type-based matching is only done at
compile time and at run-time only the number of arguments are used as
the basis for finding a match. In cases like the above, type matching
needs to happen happen at both compile and run-time.
Also, it would be nice if the GenericProc.add method was exposed as a
scheme function/macro, so that one can "incrementally" add methods to a
generic proc, e.g.
(define f (make-procedure))
(add-method f (lambda ((x :: <int>)) x))
(add-method f (lamdda ((x :: <string>)) y))
I know I can achieve the same result by just calling the GenericProc.add
java method, but that feels like cheating :)