[iterate-devel] Fwd: if-first-iteration, a little better vers ion as an arch patch
Attila Lendvai
attila.lendvai at gmail.com
Tue Jan 10 15:14:50 UTC 2006
On 1/10/06, Hoehle, Joerg-Cyril <Joerg-Cyril.Hoehle at t-systems.com> wrote:
> Attila Lendvai wrote:
> >And finally a new version of if-first-iteration:
> That's more or less that, minor a few points (a documentation string, bind step-body after first-usage to avoid setf, usage of make-accum-var-binding, and probably eliminate the no-else code generation test (let the compiler do that)).
>
> I'll add it to the next version (not immediately, I'm too busy right now). I hope this is ok.
Sure! I assume from your mail that you are planning to do all this
when you get to it (this entire stuff is probably a few minutes for
you probably :). I will keep on playing with it mostly for my own
education, and if I'm faster then you can get to it i will send
another patch.
One more thing, tough: now that I was looking at it from a birds view,
I think a first-iteration-p would be more useful then an entire if-...
construct. Same for first-time-p
> BTW, what's the iteration pattern that lead you to define this and not use IF-FIRST-TIME? Could you show some sample/imaginary code?
I use it in a test-case defining macro, which iterates on it's body
where each car is a type specifier, similar to :method in defgeneric.
But at the first element it's optional, in which case the entire body
is interpreted as one element of a default type (one less level of
parens).
IIRC something like:
(iter (for (type . body) in bodies)
(cond
((eq type :test)
(collect `(... , at body)))
(...)
(t
(if-first-iteration
(return `(... , at bodies))
(error "Unexpected typeless element encountered, only
the first element may be typeless"))..).)...)...)) :)
And btw this is the same place where I'd love to have the mentioned
"it" reference:
(finally (return `(progn , at it)))
> Thanks for your contribution.
My pleasure! I've learned a lot about compiled DSL's, or however it's
named, from iterate.
- attila
More information about the iterate-devel
mailing list