Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Your analyst has you mixed up with another patient. Don't believe a thing he tells you.


comp / comp.lang.lisp / Re: How do you insert declarations into loops?

SubjectAuthor
o Re: How do you insert declarations into loops?B. Pym

1
Subject: Re: How do you insert declarations into loops?
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 2 Jul 2024 10:24 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: How do you insert declarations into loops?
Date: Tue, 2 Jul 2024 10:24:36 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <v60kh1$1jp18$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Tue, 02 Jul 2024 12:24:36 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="a5ce9095f63423d5c7f6062626603d29";
logging-data="1696808"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ETIN5J/UReXU7ZP1N32fu"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:tRXmBu3r/IVIuhYLU5jnkNSZMh0=
View all headers

Thomas A. Russ wrote:

> > Example: This function loops over a list of associations
> > collecting the cdrs.
> >
> > (defun list-cdrs (list)
> > (loop for (unwanted-var . wanted-var) in list
> > collect wanted-var))
> >
> > When I compile list-cdrs, I get an "unused lexical variable, UNWANTED-VAR"
> > message (this is fine.). Normally, if I wanted to inhibit this
> > warning I would stick a (declare (ignore unwanted-var)) in the
> > beginning of the function body immediately following the declaration.
> > It doesn't seem that you can do this using loop.
>
> The solution is not to introduce an ignore declartion, but instead to
> use a hack in the destructuring pattern matcher:
>
> (defun list-cdrs (list)
> (loop for (NIL . wanted-var) in list
> collect wanted-var))

(map cdr '((a . 2) (b . 3)))
===>
(2 3)

1

rocksolid light 0.9.8
clearnet tor