source: trunk/abcl/doc/design/amop/d-m-c-notes

Last change on this file was 13577, checked in by ehuelsmann, 13 years ago

Add D-M-C design notes.

File size: 3.1 KB
Line 
1
2Below is a DRAFT e-mail that I intend to send to the mailing list,
3however, having it in the repository (probably rephrased) is better
4long-term documentation.
5
6
7
8Over the past days, I've been working on porting SBCL's D-M-C tests to ABCL's
9test suite and testing+fixing our implementation. A number of use-cases have
10been fixed, however, I'm now down to the more complex cases, in particular
11the case for the (:arguments . lambda-list).
12
13
14Context
15-----------
16
17When handling EMF computation, there are two sets of arguments (lambda lists):
18
191. the arguments passed to the METHOD-COMBINATION through the
20   (:method-combination ...) form in the generic function definition
212. the arguments passed to the generic function when it is being called
22
23This distinction is very important, yet not particularly clear from our
24sources. The former set of arguments is available from the instantiation of
25the generic function (DEFGENERIC evaluation) and constant throughout the life
26of the GF. The latter is set of arguments is not available until the function
27is being called and will presumably be different for each invocation of the GF.
28
29The former set is passed to the D-M-C form in the second position:
30 (D-M-C <name> <arguments> ....). The latter set is made accessible by
31providing the (:arguments ...) form to the D-M-C form -- binding of the
32variables happens at "EMF-calculation-time".
33
34Current implementation
35---------------------------------
36
37Our existing implementation does not work at all with the (:arguments ...)
38option in the D-M-C definition. [SBCL didn't either, btw,
39until 0.7.<something>]
40What happens in our implementation is that the function
41STD-COMPUTE-EFFECTIVE-METHOD-FUNCTION calls a function created by the D-M-C.
42That function returns forms to be used as the EMF. S-C-E-M-F wraps the returned
43forms in a function and returns it as the EMF.
44
45This works as long as the EMF does not depend on the arguments supplied
46to the GF (generic function) call.
47
48
49The problem
50------------------
51
52Our implementation tries to access the function call parameters (resulting
53in "unbound variable errors") from the EMF-generating function. However,
54that function won't (ever) be passed the call arguments.
55
56
57The solution
58-----------------
59
60Writing down the above and taking into account that we want to cache as much
61of our EMF as possible for performance reasons as well as considering that
62the EMF depending on the function call arguments can't be cached, I think
63this is the solution:
64
65The forms being returned (and later wrapped in a lambda) should include code
66which does another code-generation step --with access to the call parameters--
67and include a call to the forms having been generated.
68
69Examples
70--------------
71
72A call to the EMF-generating function which does not depend on the call
73arguments would return something like:
74
75 '(CALL-METHOD (MAKE-METHOD (error "ABC 123")))
76
77This form will be wrapped in a lambda roughly like this:
78  (lambda (args) (macrolet ((call-method ...)) <forms>))
79
80
81A call to the EMF-generating function which *does* depend on the arguments
82would return something like:
83
Note: See TracBrowser for help on using the repository browser.