-
Notifications
You must be signed in to change notification settings - Fork 114
Lambda list in function description #442
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
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?
vlad-km
left a comment
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: |
|
I took a shot bringing this patch up to date, there is indeed a somewhat significant bundle increase. Using the original serialization ( Maybe that means we need better dumping code, but I'm not sure how to do that. Arguably I'm responsible for making the matter worse -- in bfa0180 I changed the dumping code to create a variable for every seen literal objects, but this is to make it correctly follow CLHS 3.2.4.4. Without this, the same literal object might be dump into different (non-EQ) literal objects. To do it really correctly and compactly we might need two pass, the first for reference count and the second for actually dumping, and these have to be done over the unit of files. That doesn't sound easy. |
|
A few more thing to discuss:
|
|
I would store it as a s-form, even if the package information is not that important always. But it could be if some of the arguments is a special symbol for example! Would it be possible to make this feature optional? Adding an option to decide during bootstrap if collect or discard the function lambda lists. An idea: would it work if we use a global hash tables |
|
Why, and for what purpose? |
|
Give me statistics on the use of docstring :) |
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: