-
Notifications
You must be signed in to change notification settings - Fork 67
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
Zip generator for comprehensions #65
Conversation
eeps/eep-0073.md
Outdated
|
||
When a zip generator crashes because the containing generators are of | ||
different lengths, the error message is a tuple, where the first element | ||
is the atom `bad_generators`, and the second element is a tuple that contains |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: I believe all of the errors raised by Erlang do not have a _
after bad
. You have badarg
, badfun
, badkey
, badmap
, etc. I would probably keep it consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my bad. I should write the user-facing error message, not just the internal one. Some errors in erl_error.erl
use _
though, like bad_generator
, but it's internal. Thanks for pointing it out :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, if we already have bad_generator
, then bad_generators
make the most sense. Thank you!
eeps/eep-0073.md
Outdated
then becomes a special case of comprehension where only zip generators are | ||
used. | ||
|
||
In summary, zip generator removes the user's need to call the zip function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In summary, zip generator removes the user's need to call the zip function | |
In summary, zip generators removes the user's need to call the zip function |
any number of the 3 kinds of generators above. Zip generators can be used | ||
in list, binary, or map comprehensions in the same way. | ||
|
||
For example, if the two generators in the above example is combined together |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are combined
This EEP proposes the addition of zip generators with a syntax of
&&
forcomprehensions in Erlang. The idea and syntax of zip generators (comprehension
multigenerators) was first brought up by EEP-19. Even if the syntax and
usages of zip generators proposed by this EEP is mostly the same with EEP-19,
the comprehension language of Erlang has undergone many changes since EEP-19
was accepted. With an implementation that is compatible with all existing
comprehensions, this EEP defines the behavior of zip generators with more
clarification on the compiler's part.