Subject: Clisp problem -- detecting a function

From: [email-masked]
Date: Thu, 2 Jun 1994 10:16:06 -0700

Does anybody know how I can create a conditional statement based on
whether a function foo been defined or not? What I want to say:

(if (not (function-exists 'foo))
  (load "file-containing-foo")
)

The problem is:

- (functionp 'foo) returns T whether or not the function has been
	defined, and

- (compiled-function-p #'foo) generates an error if foo hasn't been defined.

So,

- How do I detect if function foo exists? 

- Or if I can't do that, how do I use clisp to trap the error
(ignore-errors and handler-case don't seem to be there)?

thanks,

Len Wanger -- [email-masked]
Project Sequoia 2000
San DiEgo Supercomputer Center

---

From: haible (Bruno Haible)
Date: Fri, 3 Jun 94 18:20:19 +0200

> whether a function foo been defined or not?

>  (unless (fboundp 'foo)
>	(load "file-containing-foo"))

This is fine for interpreted code, but when compiling files the compiler
does not "know" that it should look at "file-containing-foo" as well.
Better use PROVIDE and REQUIRE, like this:

(eval-when (compile load eval)
  (when (fboundp 'foo)
    (pushnew ':HAVE-FOO *features*)
) )

#-HAVE-FOO (require 'module-foo "file-containing-foo")

Bruno Haible