[iterate-devel] Fwd: using keywords in clauses

Denis Budyak budden73 at gmail.com
Mon Oct 22 23:05:36 UTC 2012


Second reply to Zach which should have been sent to an iterate-devel
mailing list too.

---------- Forwarded message ----------
From: Denis Budyak <budden73 at gmail.com>
Date: Tue, 16 Oct 2012 22:15:18 +0400
Subject: Re: [iterate-devel] using keywords in clauses
To: Zach <zach.smith at colorado.edu>

Zach, list,
> Why isn't your patch
>nothing more than a single file that looks like:
>(iterate:defsynonym :for iterate:for)
>(iterate:defsynonym :collect iterate:collect)
>...
>(iterate:defsynonym :appending iterate:appending)
>Why isn't this just a small separate library called iterate-keyword
>that only exports ITERATE?
This is because synonym mechanism is not universal. It doesn't cover
cases of iterate:first-time-p, iterate:next-iteration etc. defsynonym
simply do not work for them. To make them work, one need to patch
iterate itself.

> One last thing, I would hope that you wouldn't actually attempt to
> patch iterate to not export FOR, WHILE
Of course I didn't attempt this. In fact, there is no need to use iterate
in any package, if one can use keywords. Just writing
(:import-from :iter #:iter)
would suffice.

>  Is the root of your desire to do this the
>fact that you want to use the symbols FOR, WHILE, COLLECT, etc in the
>same package that you want to use Iterate?
Iterate is a very agressive exporter of symbols :) When I started
using iterate,
I just tried to :use both :iterate and :cl-utilities and this gave me
a conflict.
One can easily imagine an applicaion (e.g. language parser) where
symbols like FOR and WHILE are treated as data and it is desirable
for them to come from specific package, not from iterate.

Some other person is likely to implement simplified "while" loop. Third
person might just try playing with iterate, and she will get conflict
in the following innocent lisp session:

; Hallo from your lisp
%(in-package :cl-user)
%(use-package :iterate)
... conflict ...
as FOR might be exported into :cl-user from loop during initialization.

> but it would also break any body's code that decided to
> (defmacro-clause :for ...)
Yes, and it is expected, but sometimes breaking changes occur
in a software.
>  (defun :go ...)
defsynonym is not a defun, it only puts a property on a symbol,
so the symbol does not change its meaning outside of iterate construct.

Just because I agree one should not normally (defun :for),
I believe that change proposed is not very harmful as it can be hardly
expected that it would break anyone's code.

If it is considered a serious threat, we could define *features* member
so that iterate could be bulid either with or without keywords support.
Unfortunately it seem to be impossible to enable keywords support
via a separate library.

Regards, Budden




More information about the iterate-devel mailing list