[Openmcl-devel] Naming anonymous functions
ron at flownet.com
Sun Mar 2 01:07:54 UTC 2014
On Mar 1, 2014, at 3:32 PM, Pascal J. Bourguignon <pjb at informatimago.com> wrote:
> 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”.
That’s actually a very good idea. It would have to be a weak hash table, and I'd need a custom print-object method for functions, but it would do exactly what I want. Thanks for the suggestion!
> 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
Why would I have to? How do you know that I’m even *able* to? I might not have control over the code that produces the functions in question.
It is not the case that everyone always has complete control of the entire body of source code for their project.
> since I would expect most anonymous functions to be lost in closures.
What difference does that make?
> Therefore modification of the sources of your program will be required
I don’t see how that follows.
> 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.
alexandria:named-lambda is just a synonym for LABELS. Not at all what I’m after.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
More information about the Openmcl-devel