emacs-devel
[Top][All Lists]
Advanced

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

Re: Codifying some aspects of Elisp code style and improving pretty prin


From: Stefan Monnier
Subject: Re: Codifying some aspects of Elisp code style and improving pretty printer
Date: Fri, 01 Oct 2021 11:26:51 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Apropos, I believe the current recommendation is to do
>     (mapconcat #'identity seqs " ")
> rather than
>     (mapconcat 'identity seqs " ")
> ie function-quoting the argument to mapconcat, apply, mapc etc, but

Indeed, the main benefit being that the byte-compiler can warn you if
the function is not known to be defined (typically because of a typo or
a missing `require`).

A side benefit is that it "does the right thing" for `cl-flet` and friends.

> 1. The elisp manual doesnʼt say that in (info "(elisp) Mapping Functions")

Not sure that'd be the best place, but we should probably adjust the
manual to encourage the use of #' to quote function names,

> 2. Emacs' code itself doesnʼt do that consistently

The difference is sufficiently unimportant that I don't see a need to
try and make it consistent in this respect.  E.g. I do change 'foo to
#'foo quite often, but only as part of other changes.

> (and we have the odd #'(lambda ...) as well

I don't see anything wrong with #'(lambda...)
[ I personally prefer to skip the #' to make the code (marginally)
  shorter, but it's purely a matter of taste and I usually try and
  refrain from making this change in existing code unless it helps make
  the code fit into 80 columns.  ]

> 3. The byte compiler doesnʼt warn about it.

Mine does ;-)
But I wouldn't want to enable such a warning by default (or at least it
should be mess a bit less eager than it is, because of the occasional false
positives).

> I believe it helps the byte-compiler generate better code, but donʼt
> know what the actual effect is.

It has no effect on the generated code.


        Stefan




reply via email to

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