This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Classes of functions?

3 posts · 2531 views

When dealing with functions in LISP it is sometimes desirable to handle them differently depending on the number of formal variables. My question: is there any possibility to define classes of functions like
"functions_of_one_variable", "functions_of_two_variables" etc? If this were possible, then one could define common methods e.g. iteration of a function of one variable etc.
To understand LISP, you must first understand LISP.

Re: Classes of functions?

If you are looking for a way to determine the lambda list of a function then: yes, it's possible. But its implementation dependent. For example, in Clozure CL you can determine the lambda list with ccl:arglist:
? (ccl:arglist #'mapcar)
->(FUNCTION LIST &REST CCL::MORE-LISTS)

Re: Classes of functions?

The old-school way would be using property lists via GET, e.g. tag the symbols of all desired functions with properties like 'one-arg, 'two-args, etc., then write a universal iteration function that reads the properties and behaves accordingly. This works with all implementations, also with the symbols in the CL package.

- edgar