[iterate-devel] Fwd: using keywords in clauses, reply 1

Denis Budyak budden73 at gmail.com
Mon Oct 22 23:04:14 UTC 2012


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 <budden73 at gmail.com>
Date: Tue, 16 Oct 2012 11:06:34 +0400
Subject: Re: [iterate-devel] using keywords in clauses
To: Zach <zach.smith at 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?




More information about the iterate-devel mailing list