Shinmera / trivial-arguments

Tiny CL library to retrieve the arguments list of a function.
zlib License
22 stars 6 forks source link

Any plans to add additional trivial functions? #5

Closed AlbertoEAF closed 4 years ago

AlbertoEAF commented 4 years ago

Hello @Shinmera , first of all I'd like to say amazing library! :D

So easy to use! I just used it to add some magic to my scripts :) With #'arglist alone one can do everything.

Would you consider adding more basic methods to do trivial operations such as counting the number of mandatory arguments? Or does it fall outside of the scope?

Don't know how to best name that but I had to write it for my case:

(defun get-function-mandatory-arguments-count (fn)
  "Returns the number of mandatory arguments in the function."
  (let ((function-arguments (arg:arglist fn))
        (special-args '(&optional &key &rest)))
    (loop for i below (length function-arguments)
       until (find (elt function-arguments i) special-args)
       finally (return i))))

Of course, if arglist returns :undefined, it will error out.

Also things like arg:has-&key , arg:get-&key, or arg:get-&optional/&key/&rest would be interesting to parse the arglist.

Shinmera commented 4 years ago

There are other libraries to do this kind of thing already and it is not within the scope of a portability library to handle this.

AlbertoEAF commented 4 years ago

Thank you! :)

On Thu, 2 Apr 2020, 07:00 Nicolas Hafner, notifications@github.com wrote:

There are other libraries to do this kind of thing already and it is not within the scope of a portability library to handle this.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Shinmera/trivial-arguments/issues/5#issuecomment-607638164, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6K4MNEI7C3ZBBNNS5V7HLRKQSXLANCNFSM4LZUTNDQ .