Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Faith: not *wanting* to know what is true." -- Friedrich Nietzsche


devel / comp.lang.lisp / Re: count in iterate

SubjectAuthor
* count in iterateAxel Reichert
`* Re: count in iterateRalph Schleicher
 `- Re: count in iterateAxel Reichert

1
count in iterate

<m2k0imcunw.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16678&group=comp.lang.lisp#16678

  copy link   Newsgroups: comp.lang.lisp
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.lisp
Subject: count in iterate
Date: Sat, 09 Oct 2021 13:19:31 +0200
Organization: A noiseless patient Spider
Lines: 73
Message-ID: <m2k0imcunw.fsf@axel-reichert.de>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="c15ba5306838b58049236d97abb65916";
logging-data="24670"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sBzZxmjRuyUgvCFb6sidytlekdx40ejk="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin)
Cancel-Lock: sha1:sx9qk5Eod4KYn2jauaF3PjjJDWw=
sha1:vFl7CGuayhQpvASvqDhESgAsXIk=
 by: Axel Reichert - Sat, 9 Oct 2021 11:19 UTC

Hello,

currently I am comparing a couple of loop styles (do, loop, iterate,
series). Playing around with the "iterate" package, I got for the
following much simplified example

(ql:quickload :iterate)
(use-package :iterate)

(iter (for i to 2)
(for matches = (count i (list 2 1 2)))
(print matches))

a strange compilation error:

Iterate, in (COUNT I #1=(LIST 2 1 2)):
#1# should be a symbol

Sure, (list 2 1 2) is not a symbol, but neither are 0, 1, or 2, the
respective results of

(count 0 (list 2 1 2))
(count 1 (list 2 1 2))
(count 2 (list 2 1 2))

and, e.g.,

(iter (for i to 2)
(for matches = 1)
(print matches))

does compile (of course with different output), as does

(iter (for i to 2)
(for matches = (count-if #'oddp (list 2 1 2)))
(print matches))

Using a helper function

(defun my-count (i) (count i (list 2 1 2)))

and then

(iter (for i to 2)
(for matches = (my-count i))
(print matches))

also compiles (with the desired output).

Then it occurred to me that iterate has a counting clause, e.g.,

(iter (for i to 2)
(counting (= i 1) into matches)
(finally (return matches)))

which it might be legal to abbreviate. And indeed,

(iter (for i to 2)
(count (= i 1) into matches)
(finally (return matches)))

behaves the same as the "counting" version. So it seems a name conflict
is causing the compilation error.

Or is something else going on here (SCBL 2.0.0, SLIME 2.24, macOS, if it
matters)?

Is there any way to access to cl-user function "count" instead of the
iterate clause "count"?

Best regards

Axel

Re: count in iterate

<868ryylrh6.fsf@ralph-schleicher.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16680&group=comp.lang.lisp#16680

  copy link   Newsgroups: comp.lang.lisp
Path: rocksolid2!news.neodome.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: rs+usenet@ralph-schleicher.de (Ralph Schleicher)
Newsgroups: comp.lang.lisp
Subject: Re: count in iterate
Date: Tue, 12 Oct 2021 07:52:37 +0200
Organization: Ralph Schleicher
Lines: 22
Message-ID: <868ryylrh6.fsf@ralph-schleicher.de>
References: <m2k0imcunw.fsf@axel-reichert.de>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="b077bdd76605bd1f7e8f1733461bc5d9";
logging-data="12726"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8dRzbVTPjGRpTGsfs4YE4PAc6q3z3rac="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:/d8PDd9WKmiXVuXLIN7ue5t8mJA=
sha1:j2hJ9to7Cj5d+wrluzCCg6nuoIQ=
 by: Ralph Schleicher - Tue, 12 Oct 2021 05:52 UTC

Axel Reichert <mail@axel-reichert.de> writes:

> (iter (for i to 2)
> (for matches = (count i (list 2 1 2)))
> (print matches))
>
> a strange compilation error:
>
> Iterate, in (COUNT I #1=(LIST 2 1 2)):
> #1# should be a symbol

Smells like a bug. You should report it to the maintainers.

> Is there any way to access to cl-user function "count" instead of the
> iterate clause "count"?

(iter (for i :to 2)
(print (funcall #'count i (list 2 1 2))))

--
Ralph

Re: count in iterate

<m2lf2y114v.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16681&group=comp.lang.lisp#16681

  copy link   Newsgroups: comp.lang.lisp
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.lisp
Subject: Re: count in iterate
Date: Tue, 12 Oct 2021 21:41:52 +0200
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <m2lf2y114v.fsf@axel-reichert.de>
References: <m2k0imcunw.fsf@axel-reichert.de>
<868ryylrh6.fsf@ralph-schleicher.de>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="c91138989fc3f72ee9c47a2e6f776987";
logging-data="24635"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+voCyf14BGfyQabBIet/Bij2GyQLqsyRA="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin)
Cancel-Lock: sha1:TQ+DTU/8cye2tRQnAuFnsGk3Tak=
sha1:vVHubWriWCTUM+z3wf5s5Etb9qI=
 by: Axel Reichert - Tue, 12 Oct 2021 19:41 UTC

Ralph Schleicher <rs+usenet@ralph-schleicher.de> writes:

> Axel Reichert <mail@axel-reichert.de> writes:
>
>> (iter (for i to 2)
>> (for matches = (count i (list 2 1 2)))
>> (print matches))
>>
>> a strange compilation error:
>>
>> Iterate, in (COUNT I #1=(LIST 2 1 2)):
>> #1# should be a symbol
>
> Smells like a bug. You should report it to the maintainers.

In

https://gitlab.common-lisp.net/iterate/iterate/-/blob/master/iterate.lisp

I could find the suspicious

(defparameter *deprecated-clause-names* '((count . counting)))

and some line further down (reformatted here) the explanation:

(format stream "~s appears to be used as an ITERATE clause keyword, in
this sexpression: ~S. ~ This use is now deprecated and will cease to
be ~ supported in a future version. ~@[Please use the alternative
keyword ~s instead.~] If you intended ~2:*~s to ~ be interpreted as a
function call, instead of an ITERATE clause, you must find an
alternative way of calling it, ~ at present, perhaps by using FUNCALL
or APPLY." keyword clause substitute keyword)

My iterate.lisp is older and does not yet contain (and thus not issue)
this warning. As for your workaround: You nailed it!

For the record: It was a known issue, see

https://gitlab.common-lisp.net/iterate/iterate/-/issues/1

For your help: Thanks!

Axel ...

P. S.: ... who has meanwhile used functions returning functions, which
made the code much smaller and got rid of lots of "iter" forms
alongside.


devel / comp.lang.lisp / Re: count in iterate

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor