unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Any reasons against having `fboundp-and-funcall' (equivalent to `bound-and-true-p')?
@ 2023-06-21 14:29 Jens Schmidt
  2023-06-21 15:02 ` [External] : " Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: Jens Schmidt @ 2023-06-21 14:29 UTC (permalink / raw)
  To: emacs-devel

I was delighted when I recently came across `bound-and-true-p' in 
standard Emacs.  But what about `fboundp-and-funcall'?  Like this:

(defmacro fboundp-and-funcall (function &rest arguments)
   `(let ((function ,function))
      (and (fboundp function)
           (funcall function ,@arguments))))

;; arguments not eval'ed in case of failure
(fboundp-and-funcall #'foo (setq baz 'bar))
nil
(boundp 'baz)
nil

(fboundp-and-funcall #'identity 'foo)
foo

WDYT?



^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [External] : Any reasons against having `fboundp-and-funcall' (equivalent to `bound-and-true-p')?
  2023-06-21 14:29 Any reasons against having `fboundp-and-funcall' (equivalent to `bound-and-true-p')? Jens Schmidt
@ 2023-06-21 15:02 ` Drew Adams
  0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2023-06-21 15:02 UTC (permalink / raw)
  To: Jens Schmidt, emacs-devel@gnu.org

> WDYT?

I think "Why?".

The trivial expansion is just as clear (nay, clearer), and nearly as succinct.

(and (fboundp function)
     (funcall function ,@arguments))))
___

Just one opinion.

(Of course, I feel the same about `bound-and-true-p', which has the additional disadvantage that its name doesn't proclaim that it returns the variable's symbol.)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-21 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-21 14:29 Any reasons against having `fboundp-and-funcall' (equivalent to `bound-and-true-p')? Jens Schmidt
2023-06-21 15:02 ` [External] : " Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).