[Openmcl-devel] Naming anonymous functions

Pascal J. Bourguignon pjb at informatimago.com
Sat Mar 1 23:32:43 UTC 2014


Ron Garret <ron at flownet.com> writes:

> Is there any way to give a name to an anonymous function after it has
> been created?  Looking at the objects produced by LAMBDA and
> CCL::NLAMBDA it appears the only difference between them is that
> anonymous functions have name of NIL, but as these are not
> standard-objects I can’t figure out how to change this value.  (I
> tried reverse-engineering the code that creates them in nx1.lisp but I
> got lost in a twisty little maze of S-expressions.)
>
> (FYI, the reason I want to do this is to facilitate debugging an
> application that has a lot of anonymous functions floating around.)

For debugging purposes, conformingly you could merely put the functions
in a hash-table with their "name".

But the question is how you assign names to the numerous anonymous
functions you have.  You'd have to name them at their place of creation,
since I would expect most anonymous functions to be lost in closures.
Therefore modification of the sources of your program will be required
anyways.

Therefore alexandria:named-lambda is the best option so far, it doesn't
seem to let you assign a dynamic name to the lambda, so you may want to
modify if you generate anonymous closures you want to give different
names to.


-- 
__Pascal Bourguignon__
http://www.informatimago.com/
"Le mercure monte ?  C'est le moment d'acheter !"




More information about the Openmcl-devel mailing list