Skip to content

Commit

Permalink
Added apply-if-exists
Browse files Browse the repository at this point in the history
darcs-hash:20080526151359-3cc5d-643a522cb11ca8928d27fc9c7c0f8d620fbb4c81.gz
  • Loading branch information
Gary King committed May 26, 2008
1 parent 3ea58ac commit 25350d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
18 changes: 12 additions & 6 deletions dev/l0-utils.lisp
Expand Up @@ -247,9 +247,15 @@ not sticky."
((ensure (not (dotted-pair-p '(a b . c)))))
((ensure (not (dotted-pair-p nil))))))







(defun apply-if-exists (function package &rest args)
"If the function `function` can be found in `package`, then call it
with `args`.
Returns nil if `package` does not exist or if `function` does not name a
function in `package`. Otherwise, returns whatever `function` returns."
(let ((package (find-package package)))
(when package
(let ((symbol (find-symbol function package)))
(when (and symbol (fboundp symbol))
(apply symbol args))))))

3 changes: 3 additions & 0 deletions dev/package.lisp
Expand Up @@ -35,6 +35,9 @@

#:without-interrupts)

(:export
#:apply-if-exists)

(:export
#:defclass-property
#:deprecated
Expand Down

0 comments on commit 25350d7

Please sign in to comment.