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]

Re: generic procedures


Matthias Radestock <matthias@lshift.net> writes:
> 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.

Yes and no.  The GenericProc *framework* handles run-time type-based
selection when you have more than one candidate MethodProc matching
just fine.  The problem is the specific implementation of MethodProc
by the class ModuleMethod doesn't implement 'match' correctly.  (There
is a FIXME above ModuleMetod.match to that effect.)

The problem is that match does not have the needed information to do
the type tests.  The compiler for 'apply1' generates explicit inline
code to do the type tests and conversions, but it doesn't generate
any convenient run-time data structure that 'match' can use.  This
needs to be done, but I haven't had time yet.  Once that is done
we get the issue of whether 'apply' should use the run-time
data-structure or use specially-generated code.  The former is
more compact (especially in you want good error messages); the
latter is faster.  Ideally, it should probably depend on programmer
preference set using command line options (for example whether -O
is specified).

I don't know when this would get done.  I have many more urgent tasks, so
unless someone else does it, or there is a lot of clamor for the feature,
or a paying customer wants it, or the mood takes me, it may be a while.

> 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 :)

That would be relatively simple, but perhaps not much point until
generics are really usable.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

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