cl4py icon indicating copy to clipboard operation
cl4py copied to clipboard

What is a `<cl4py.lisp.function object at 0x1167ef650>`?

Open rpgoldman opened this issue 5 years ago • 2 comments

I'm getting an error inside lisp code, and I'm trying to see what's going on, but it's happening in evaluation of a Lisp expression with the above object in it.

Is there any way to look at this object and find out what its name is in the CL environment? I don't see anything using dir that helps me out.

If there is a way to get the function name out, it would be great if we could print the name -- currently this representation is not very helpful.

rpgoldman avatar Sep 14 '20 22:09 rpgoldman

All non-serializable objects are represented by a handle (an integer) and the name of the object's class (a symbol). Functions are represented this way, so pure Python code cannot tell you much about this object.

My suggestion is that you could try calling cl.describe_object on it, or some implementation specific function for figuring out the name or lambda list.

marcoheisig avatar Sep 15 '20 06:09 marcoheisig

I could write a __repr__ method for LispWrapper objects that attempts to retrieve some more metadata like a function's name and lambda list. The question is whether this mechanism should be generalized somehow.

For example, I could define a generic function cl4py:object-info that returns a list of things that are then transmitted to Python and shown as part of an object's __repr__. I only wonder whether this data should be cached on the Python side or not. Caching would avoid additional control transfers to Lisp. Not caching would also correctly display mutable information. Any thoughts?

marcoheisig avatar Nov 19 '21 12:11 marcoheisig