[Openmcl-devel] GF invocation protocol
pc at p-cos.net
Tue Sep 18 16:57:19 UTC 2007
This looks very interesting. Maybe I'll add this to Closer to MOP -
or are there plans to add this to OpenMCL directly?
The two cases %%one-arg-dcode and %%1st-two-arg-dcode look the same
to me, but it seems to be that this is correct, right?
Have you been able to "convince" other CL implementations as well to
make compute-discriminating-function work?
On 18 Sep 2007, at 06:40, Vyacheslav Akhmechet wrote:
> On 9/12/07, Gary Byers <gb at clozure.com> wrote:
>> If you wanted to pursue this, it might be helpful to know that
>> ccl::%%one-arg-dcode expects the arguments (DT ARG)
>> ccl::%%1st-two-arg-dcode expects the arguments (DT ARG0 ARG1)
>> All other dcode functions expect the arguments (DT ARGS)
>> I think that this all qualifies as "low-level gunk".
> Thank you, this was very useful. Here's a follow up, in case anyone is
> I've spent the past week porting my code to various implementations.
> OpenMCL actually turned out to be pretty easy. I first defined
> compute-discriminating-function method on standard-generic-function.
> It doesn't hurt because OpenMCL never calls it and it provides
> functionality that allows easy specialization of
> compute-discriminating-function on subclasses of
> (defmethod compute-discriminating-function ((gf standard-generic-
> (let ((std-dfun (ccl::%gf-dcode gf))
> (dt (ccl::%gf-dispatch-table gf)))
> (lambda (&rest args)
> (case (ccl::function-name std-dfun)
> (ccl::%%one-arg-dcode (apply std-dfun dt args))
> (ccl::%%1st-two-arg-dcode (apply std-dfun dt args))
> (t (funcall std-dfun dt args))))))
> This function can be optimized (no need to keep the branching within
> the returned lambda, it can be pushed outside) and ccl::function-name
> can probably fail at some point, but the code conveys the basic idea
> (and so far works well).
> I then specialized :after methods of add-method, remove-method,
> initialize-instance (for GFs and methods), and reinitialize-instance
> (also for GFs and methods) to call set-funcallable-instance on the GF
> and set it to the result of compute-discriminating-function called on
> the GF. I do these specializations on my subclasses of
> As part of my application I specialize compute-discriminating-function
> on my custom generic functions and this code works exactly the same
> way as it does on other implementations - it can close over
> (call-next-method) and later invoke that function. Effectively the
> default specialization of compute-discriminating-function on
> standard-generic-function acts as a generator of a trampoline.
> Hope this makes sense and people find it useful.
> Slava Akhmechet
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium
More information about the Openmcl-devel