[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

functionp/fboundp



	From:	RHEA::DECWRL::""Gail Zacharias" GZ%OZ.AI.MIT.EDU@XX.LCS.MIT.EDU" 22-JAN-1987 12:37
	To:	common-lisp@SAIL.STANFORD.EDU
	Subj:	symbol-function of non-functions

	The manual seems to imply that fboundp is required to return non-nil
	for macros and special forms, while symbol-function is merely allowed
	to do so (".. function or MAY be an object representing a special form
	or macro..").  Am I reading that right?

	In any case, it seem to me that these definitions make it impossible
	to tell for sure whether a symbol is a valid argument to APPLY/FUNCALL.
	I.e. in implementations which do not keep macros in the function cell,
	so that macro-function being true does not imply non-applicability of the
	symbol, there is no CL way to find out if there is an applicable definition
	regardless of whether there is or isn't a macro definition.

In VAX LISP, the function FUNCTIONP returns true if the argument can be
used in a call to FUNCALL or to APPLY.  Unfortunately, notes sent to this
mailing list have indicated that in other implementations FUNCTIONP returns
true for all symbols, regardless of the current symbol-function cell contents.
In those cases you could write your own version of functionp to say
(defun apply-argument-p (x)
  (if (symbolp x)
      (and (fboundp x)
           (not (macro-function x))
           (not (special-form-p x)))
      (functionp x)))

	Why not require fboundp be true if and only if there is an applicable
	definition.  You could still say (or (macro-function x) (special-form-p x)
	(fboundp x)) if you really want to include all possibilities, while there is no
	way to implement the more restrictive fboundp in terms of what's currently
	documented.

You can also now determine what you want by using the form written above.

Beryl Nelson
nelson%bach@decwrl.dec.com