-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
idea: making arguments more consistent #65
Comments
If we went the route of passing multiple lists to
I think that it could be interpreted like either of the following. (seq-doseq (a '(1 2 3 4))
(seq-doseq (b '(5 6 7 8))
(seq-doseq (c [9 10 11 12])
(seq-doseq (d [13 14 15 16])
loopy--main-body))))
(seq-doseq (a '(1 2 3 4))
(seq-doseq (b [9 10 11 12])
(seq-doseq (c '(5 6 7 8))
(seq-doseq (d [13 14 15 16])
loopy--main-body)))) For that reason, I think it is better to have nested loops come from a special macro argument, instead. For example, there could be a generic In this case, using a special macro argument would remove any ambiguity caused by multiple loop commands, as there would only be one occurrence allowed. Another interpretation is to "distribute" the elements of the list, in effect iterating through A third possibility is to treat multiple arguments as iterated through in parallel, similar to Python's |
Based on what you mentioned I like the "distribute" option best. I am biased though, because I think that the distinction in syntax between single nesting and multiple nesting caused by using a separate macro argument is more of a distraction. I like the idea of abstracting "looping" in general by which I mean, transitioning between a single-nested and multi-nested loop in a fluid way (without extra keywords). I can see perhaps a flag for this option for those who prefer using an extra macro argument. |
There's only a practical difference if using multiple sequences in multiple iteration commands. For only iterating via 1 iteration commands, the behavior is the same except that the distribution is done before the loop begins.
Since multiple sequences was also added to the The behavior of ((seq-doseq (a '(1 2 3 4))
(seq-doseq (b '(5 6 7 8))
(seq-doseq (c [9 10 11 12])
(seq-doseq (d [13 14 15 16])
loopy--main-body)))) can just be achieved using (loopy (seq (a b c d)
'(1 2 3 4) '(5 6 7 8)
[9 10 11 12] [13 14 15 16])
stuff) It took a while, but #73 has been merged. Please try these new features out at your convenience. |
Now that we seem to be introducing keywords as a way to specify additional arguments for clauses, it may be worth doing the same for things like
list
which can optionally take FUNC.This would increase consistency.
Furthermore doing so would allow easy incorporation of #27. The signature for
list
could be(list elt list &rest lists &key func)
. If where if multiple lists are specified, it would perform a nested loop. So if(list var '(1 2 3) '(3 4 5))
, thenvar
would get the value(1 3)
for the first iteration,(1 4)
for the second and so on.The text was updated successfully, but these errors were encountered: