-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lambda list in function description #442
base: master
Are you sure you want to change the base?
Conversation
Is it possible to add correct handling of CL-USER> (setq kik (lambda (x &optional y) nil))
#<FUNCTION>
CL-USER> (describe 'kik)
KIK
Class: #<builtin-in-class SYMBOL>
:INTERNAL in package CL-USER
Print name: "KIK"
KIK names a special variable
Value: #<FUNCTION>
#<FUNCTION>
Class: #<builtin-in-class FUNCTION>
Name:anonimous
Lambda list:NIL
CL-USER> (defun kek (x &optional y) (cons x y))
KEK
CL-USER> (describe 'kek)
KEK
Class: #<builtin-in-class SYMBOL>
:INTERNAL in package CL-USER
Print name: "KEK"
KEK names a function
#<FUNCTION KEK>
Class: #<builtin-in-class FUNCTION>
Name:KEK
Lambda list:(X &OPTIONAL Y) |
Can we expose this under a I wonder also if it'd be a good idea to make this pluggable somehow. We could define a That way there is no need to pay the price for the extra bundle if desired. That would allow to change it dynamically too. Thoughts? |
I don't understand what you want here ...
I've no problem with that. I would set it to true by default. I've no problem with not making it optional either; CL implementations usually come with this, with no optionality.
|
I don't know yet.. but I can have a look. |
Ah. You just want a function that returns the lambda-list. Of course!. |
Would also be nice to attach lambdalists to generic functions and methods. Not done atm. |
I'm including a custom writer for functions that show lambda-lists. Looks like this:
|
I was wrong. This is already being done:
|
I've implemented it:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be
(defun function-object-printer (form stream)
(let ((res)
(fname (oget form "fname"))
(ll-form (function-lambda-list form)))
(setq res (concat (if fname "#<FUNCTION " "#<LAMBDA ")
(if fname
fname
"")
(if ll-form
(princ-to-string ll-form)
"()")
">"))
(simple-format stream res)))
Mmm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(defun function-lambda-list (function)
"Return the lambda-list of FUNCTION."
(read-from-string (oget (fdefinition function) "lambdalist") nil))
Mmm?
"Return the lambda-list of FUNCTION." | ||
(let ((lambda-list (oget (fdefinition function) "lambdalist"))) | ||
(when lambda-list | ||
(read-from-string lambda-list)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the comments, this feels a bit weird.
We could just dump the lambda-list with literal
from the compiler I guess so there is no need to re-read it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I dumped it as a string. I'm not expert on the compiler internals.
I should revert that. I was playing a bit with the printing of lambda expressions. In SBCL for example, the lambda list is printed: |
Can we have the lambda-list of functions as part of their descriptions.?
It is useful to have them for tools also.
Description of function after this: