> Which is what makes a macro like this so hairy: the inconsistency.
Yes.
> There are the lexical bindings you want to use as iteration variables [...] and the ones you want to iterate over
Yes "context" stuff. See Perl.
> Maybe what you want to do is specialize on whether the second parameter evaluates to an iterable object?
Yes, it may be a way.
> don't know if I'd like seeing this in use -- complexity creep.
You are certainly wise here :-).
But you know, I don't care of 'each. It's OK if in current Arc it is too tricky to have, and I don't try anymore to have it work my way. It will anyway always be tricky and whether something like this should be used is another debate.
Actually what I care more about is the 'if behaviour. Everyone here seems to ignore this eventual issue and focus on the precise problem of 'each, but this was not my point initially.
ignore this eventual issue and focus on the precise problem of 'each
Certainly. It was in the back of my head when I wrote my reply. I didn't mention it because I was trying to be terse (I have a problem being long-winded), so opted to focus on something small in my post.
But I agree: macroexpansion time is kind of fuzzy in Arc. It even gets in the way of things like
arc> (let do [+ _ 1] (do 1 2 3))
3
which has been a source of hand-waving for awhile with no clear answer: http://arclanguage.org/item?id=9696. But that's another story (in a manner of speaking).
Not to pick on the intended each behavior (after all, why bother writing code if you don't like how it looks?) or the actual topic of this post.
Thanks for the link and (let do ...) example. Interesting to read.
> macroexpansion time is kind of fuzzy in Arc
Well, this was the point of this post! It is important to know about the "limits" of your macros system. As CatDancer mentioned it, there are differences between them.
The catch phrase "macros are evaluated at expansion time, functions at runtime, ..." is too simplistic and doesn't provide enough knowledge at some point.
> why bother writing code if you don't like how it looks?