This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: KAWA - define-generic



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. 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.

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.


Per Bothner wrote:


Chris Bitmead wrote:

Is there something in Kawa like define-generic?

There is 'make-procedure' (which is documented in the manual),
and 'define-procedure' (which isn't documented but should be).
Both of these require that all the methods be supplied in the
call to 'make-procedure' or 'define-procedure'.

It should be easy enough to implement define-generic and
define-method, but I haven't.

In any case, the support for generics needs a bit of work.
The *intent* is that the following shuld work:

(define-procedure Plus
  (lambda ((x :: <number>) (y :: <number>)) (+ x y))
  (lambda ((x :: <string>) (y :: <string>)) (string-append x y)))

- but it doesn't.  I don't know when I can get it working.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]