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: Drew Adams
Subject: RE: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?
Date: Thu, 7 Jan 2021 19:03:06 -0800 (PST)

> 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,

FWIW, Common Lisp has several iteration constructs that let you specify an 
optional return value up front (as you would say, in a sub-sub-expression).  
Not just `dolist' and `dotimes'.  `do', for instance.

There's nothing particularly odd, new, or unlispy about such design.  It's very 
old in Lisp iteration.

And most such iteration constructs wrap everything in an implicit nil block, so 
you can also use `return' anywhere to return a value.

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node88.html



reply via email to

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