help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to avoid compiler warning `unused lexical variable' for `dolist'


From: Stefan Monnier
Subject: Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?
Date: Thu, 07 Jan 2021 21:21:23 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> Indeed, I don't like this 3-arg form of `dotimes` and `dolist` because
>> it tends to "hide" the return value.  But we keep it because there's
>> something to be said for not being "gratuitously" different from
>> Common-Lisp.
>
> I do not see how it hides when I know how it is used from Common
> Lisp.  So I look there in third value and I know which one will be
> returned.

It's hidden because it's not at the usual place where the return value
is usually placed (i.e. in the last expression).

There are several other macros/specialforms that also place the return
value elsewhere than the last expression, such as `unwind-protect`, (and
to a lesser extent `if`, `cond`, `condition-case`, `prog1`), but these
still place the return value in one of the immediate subexpressions,
many of them use indentation to try and make the return value "stand
out" from the rest, etc...

In contrast in `dotimes` and `dolist` it's placed in
a sub-sub-expression and moreover it's one that's rarely used (arguably
*because* it's too deeply nested), so you're likely to miss it if you
don't go looking for it very actively.

Not that it matters anyway,


        Stefan




reply via email to

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