Discussion:
using keywords in clauses, reply 1
Denis Budyak
2012-10-22 23:04:14 UTC
Permalink
Content preview: Hi list! I see I didn't send my reply to Zach into a iterate-devel
mailing list, by omission. I think now it is the time to correct that. Forwarded
message From: Denis Budyak Date: Tue, 16 Oct 2012 11:06:34 +0400 Subject:
Re: [iterate-devel] using keywords in clauses To: Zach [...]

Content analysis details: (-0.4 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.219.51 listed in list.dnswl.org]
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider
(budden73[at]gmail.com)
-0.0 SPF_PASS SPF: sender matches SPF record
0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in
digit (budden73[at]gmail.com)
0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid
Archived-At: <http://permalink.gmane.org/gmane.lisp.iterate.devel/194>

Hi list!
I see I didn't send my reply to Zach into a iterate-devel mailing
list, by omission. I think now it is the time to correct that.

---------- Forwarded message ----------
From: Denis Budyak <***@gmail.com>
Date: Tue, 16 Oct 2012 11:06:34 +0400
Subject: Re: [iterate-devel] using keywords in clauses
To: Zach <***@colorado.edu>

Hi Zach, list!
If you encode FOR and COLLECT as special tokens that Iterate's
parser/compiler just understands you break the extensibility.
Iterate-keywords makes minimal change to iterate. Roughly, it makes
(defsynonym :any-clause-head any-clause-head), but only for
standard iterate clauses, not for user defined. As synonyms do not
work with special clauses like (next-iteration) (it can be considered a
bug in synonym mechanism), patch to iterate itself was required.

Consequently, it does not break your example.
%(iterate-keywors:iter (test:for i in-whole-vector #(1 3)) (:collect i))
(1 3)

%(iterate-keywors:iter (:for i in-whole-vector #(1 3)) (:collect i))
...errs...

For is intended to be extensible via second keyword, in-whole-vector
in our case. If we define it as in manual,
%(in-package :iterate-keywords)
%(defmacro-clause (FOR var IN-WHOLE-VECTOR v) ...),
It will work with iterate-keywords as intended:
%(in-package:cl-user)
%(iterate-keywords:iter (:for i in-whole-vector #(1 3)) (:collect i))
(1 3)
If we define any new clause, iterate-keywords won't touch it.
We can define it in :test package and use the symbol
from that package, that is,
%(iter (test:our-clause))
Additionally, we can make
%(defsynonym :our-clause test:our-clause)
and thus enable ourselves to use keyword:
%(iter (:our-clause))
and even then, it would suffer from name collisions inherent in the keyword package
Most of iterate keywords are in a keyword package already as they are
used in common lisp loop macro. What kind of collision do you mean?
Loading...