[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Partial wdired (edit just filename at the point)
From: |
Stefan Monnier |
Subject: |
Re: Partial wdired (edit just filename at the point) |
Date: |
Mon, 22 Mar 2021 18:16:59 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> ELISP> (eval (byte-compile '(type-of #'(lambda () 42))))
> compiled-function
>
>> And FWIW, I'd like to get to the point where (type-of (lambda () 42))
>> never returns `cons` but always some kind of "function" type instead,
>> indeed.
>
> Do you mean more like the Common Lisp behaviour?
>
> Getting back to the original advice, in compiled code or in such `some
> kind of "function"' future, using #' will make it not possible to
> redefine wdired--preprocess-line in the hook:
No, I was talking about #'(lambda...) not about #'<symbol>.
IOW, I was talking about having `lambda` returning an actual function
object instead of returning a "list that can be treated as a function".
The use of #'<symbol> to refer to the actual symbol (so that it will
change its semantics whenever that symbol's definition is changed) is
much too ingrained in ELisp, I think changing it would introduce a lot
of breakage and I'm not sure what the benefit would be: there's already
`symbol-function` for that.
> I would like to understand when to prefer #' and when '.
Use #' when you refer to a function by name, use ' when you're just
referring to the symbol for some other reason (it might be a face,
a variable's name, some arbitrary constant, ...).
My rule of thumb is to write #'<foo> whenever I could also place here the
content of (symbol-function 'foo), just with a slightly different semantics.
For example, I prefer to write
(defalias 'foo #'bar)
because it does something quite similar to
(defalias 'foo (symbol-function 'bar))
whereas it does something very different from
(defalias (symbol-function 'foo) #'bar)
-- Stefan
- Sv: Sv: Partial wdired (edit just filename at the point), (continued)
- Sv: Sv: Partial wdired (edit just filename at the point), arthur miller, 2021/03/20
- Re: Partial wdired (edit just filename at the point), Tomas Hlavaty, 2021/03/21
- Re: Partial wdired (edit just filename at the point), tomas, 2021/03/22
- Re: Partial wdired (edit just filename at the point), Arthur Miller, 2021/03/22
- Re: Partial wdired (edit just filename at the point), tomas, 2021/03/22
- Re: Partial wdired (edit just filename at the point), Stefan Monnier, 2021/03/22
- Re: Partial wdired (edit just filename at the point), Tomas Hlavaty, 2021/03/22
- Re: Partial wdired (edit just filename at the point), Andreas Schwab, 2021/03/22
- Re: Partial wdired (edit just filename at the point), Stefan Monnier, 2021/03/22
- Re: Partial wdired (edit just filename at the point), Tomas Hlavaty, 2021/03/22
- Re: Partial wdired (edit just filename at the point),
Stefan Monnier <=
- Re: Partial wdired (edit just filename at the point), Tomas Hlavaty, 2021/03/22
- Re: Partial wdired (edit just filename at the point), Andreas Schwab, 2021/03/22