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


    Date: Saturday, 26 April 1986  12:19-EST
    From: David Bein <pyramid!bein at SUN.COM>
    Re:   funcall

      Suppose we have the following code:

      (defun mumble (a)
    	(flet ((mumble (a) (print "internal-mumble")))
    	      (when (something a) (funcall 'mumble a))
    	      (print "external-mumble")

      Is it 100% legal to pass funcall a symbol? Most implementations I
    have seen allow this although the manual tends to imply that the
    thing being funcall'ed must be a "function".
It is pretty clear that passing a symbol to FUNCALL is legal.
Although it doesn't say so in the funcall description, it is
explicitly allowed in APPLY.  It would be pretty silly not to apply
the same rule to FUNCALL.  I would say that regardless of whether a
symbol is a function or not, it is legal to pass a symbol to FUNCALL.

      Is a compiler justified in simply turning this into a call to mumble
    as if it had been written as (mumble a) in the first place?
No, as in APPLY, calling a symbol calls the global definition.

      Another related matter, suppose we change the funcall arg to
    #'mumble --> (function mumble). Is it clearly the case then that
    the mumble which is apparent is the inner one?
Yes, FUNCTION evaluates a "functional expression" in the lexical
environment at the point of call.