[GSoC] Parameter protocols in CL

Charles Turner chturne@gmail.com
Tue Jul 17 22:19:00 GMT 2012


On 16 July 2012 21:53, Helmut Eller <eller.helmut@gmail.com> wrote:
> For &optional arguments you can tell it from the number of arguments.
> Each argument count [argmin..argmax] gets an "entry point" (see
> LambdaExp#primMethods); defaults are computed there before
> (tail-)calling the "main" method with the full number of arguments.
>
> It seems that LambdaExp#addMethodFor decides which entry points are
> needed.  Code generation happens in LambdaExp#compileAsMethod which
> loops over the LambdaExp#primMethods for &optional entry points and
> calls LambdaExp#enterFunction for the main entry point.

I'm still struggling to figure this out. For an expression like:

((lambda (&optional (a 1) (b 2)) (list a b)) 10 20)

I struggle to follow the code to what happens. I *think* something like:

meth0 () { meth2(1, 2); }
meth1 (a) { meth2(a, 2); }
meth1 (b) { meth2(1, b); }
meth2 (a, b) { list(a, b); }

And your suggestion is something along the lines of:

meth0 () { meth2(1, 2, false, false); }
meth1 (a) { meth2(a, 2, true, false); }
meth1 (b) { meth2(1, b, false, true); }
meth2 (a, b, asup, bsup) {
   initialise asup and bsup declarations with appropiate lang bools.
   list(a, b);
}

That's what I think should happen, as for generating the method
parameters, I'm still not confident I know how to do that.

Sorry if I've totally missed the point, I'm finding this code quite
hard to follow.

Per, re the "code not executed" point, what I said was not what I
meant :-). The code starting from line 1440 in LambdaExp#enterFunction
looks like it does exactly what I'm talking about, consulting the VM
registers and acting on that information. *This* code is not executed,
because the

if (plainArgs >= 0 || ! param.isSimple()
	    || param.isIndirectBinding())

condition is not satisfied with the examples above.

Also, in (&optional (a 2 a-p)), I'm making a Declaration out of A-P
and adding it to the A declaration (a new field in Declaration). This
really doesn't feel right, but how else are you going to associate the
two declarations?

Apologies for the lack of learning curve crampons.

Charlie.



More information about the Kawa mailing list