emacs-devel
[Top][All Lists]
Advanced

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

Re: #'quoting functions when they are used as identifiers


From: Sean Whitton
Subject: Re: #'quoting functions when they are used as identifiers
Date: Sun, 27 Mar 2022 11:58:32 -0700
User-agent: Emacs/29.0.50 (x86_64-pc-linux-gnu)

Hello,

On Sun 27 Mar 2022 at 02:27pm +02, Jonas Bernoulli wrote:

> I was wondering whether it is wrong per se to function-quote a
> function-bound symbol if it serves as an argument to a function that
> does not actually call the argument as a function but for which it
> would never-the-less be a bug to be passed a symbol that isn't bound
> as a function.

I've struggled with this.  If you assume that sharpquote has the same
meaning (ignoring implementation) as the sharpquote in Common Lisp, then
I can give an answer.  Suppose that you are choosing between (f #'foo)
and (f 'foo).  Then

  - use #'foo if f will do something with the function object which may
    be invoked using (foo ...) in the lexical environment in which the
    (f #'foo) would occur

  - otherwise, use 'foo, because f will do something with the symbol
    `foo', but not its function binding.

> I am considering adding #'quotes because I would like to get that
> feedback from the byte-compiler.  On the other hand, one might argue
> that doing that is misleading to the human reader because the symbol
> is not actually intended to be called as a function, it just has to be
> a symbol that is fboundp, else there would be a bug (due to a typo or
> renaming).

According to the CL meaning for sharpquote, this wouldn't make sense.  I
think I'd find it confusing myself, but then, I write lots of CL.  I
really don't know how close the Emacs Lisp sharpquote is meant to be to
the CL sharpquote.

The technical difference is that CL doesn't have symbol function
indirection as described by (info "(elisp) Function Indirection").

-- 
Sean Whitton



reply via email to

[Prev in Thread] Current Thread [Next in Thread]