-
Notifications
You must be signed in to change notification settings - Fork 88
function exists?
Peter Lewis edited this page Sep 30, 2020
·
4 revisions
function-exists? tests if a function named str exists.
| Parameter | Description |
|---|---|
| str | String to test for existance |
Example 1: Check if a function "s5-init", which is declared in a different module, exists to add a new monitor driver to an existing list of supported drivers.
(if (function-exists? "s5-init")
(eval '(monitor-add-driver (list "S/5" s5-init s5-run s5-close))))
If the string being tested is used elsewhere in the code as a symbol, function-exists? may return true. For example:
(display 'hello)
(function-exists? "hello")
displays 'hello' and returns #t. This can occur even when the symbol usage is after the call to function-exists?. To avoid this, use only strings as parameters for this function and avoid using that string as a symbol anywhere in your code.