-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
formatting and more explanation for error
- Loading branch information
Showing
1 changed file
with
11 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ EEP 73: Zip generator | |
Abstract | ||
======== | ||
|
||
This EEP proposes the addition of zip generators with a syntax of `&&` for | ||
This EEP proposes the addition of zip generators with a syntax of `&&` for | ||
comprehensions 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, | ||
|
@@ -72,11 +72,10 @@ produces a binary, etc. | |
<<Expression || Qualifier(s)>> %% Binary Comprehension | ||
#{Expression || Qualifier(s)} %% Map Comprehension | ||
|
||
|
||
Qualifiers can have the following kind: filter, list generator, bitstring | ||
generator, and map generator. Except for filters, the other three kinds of | ||
qualifiers are generators. Their names refer to the type on the right hand | ||
side of `<-` or `<=`. Generators have the following form: | ||
side of `<-` or `<=`. Generators have the following form: | ||
|
||
Pattern <- List %% List Generator | ||
Pattern <= Bitstring %% Bitstring Generator | ||
|
@@ -138,12 +137,14 @@ Generators of Different Lengths | |
`lists:zip/2` and `lists:zip3/3` will fail if the given lists are not of the | ||
same length, where `zip/n` will also crash. Therefore, a zip generator raises a | ||
`bad generators` error when it discovers that the given generators are of | ||
different lengths. | ||
different lengths. | ||
|
||
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 | ||
the remaining data from all generators. | ||
different lengths, the internal error message is a tuple, where the first | ||
element is the atom `bad_generators`, and the second element is a tuple that | ||
contains the remaining data from all generators. The user-facing error message | ||
is `bad generators: `, followed by the tuple containing remaining data from | ||
Check failure on line 146 in eeps/eep-0073.md
|
||
all generators. | ||
|
||
For example, this comprehension will crash at runtime. | ||
Check failure on line 149 in eeps/eep-0073.md
|
||
|
||
|
@@ -158,7 +159,7 @@ On the compiler's side, it is rather difficult to return the original zip | |
generator in the error message, or to point out which generator is of | ||
different length comparing to others. The proposed error message aims to | ||
gives the most helpful information without imposing extra burden on the | ||
compiler or runtime. | ||
compiler or runtime. | ||
|
||
Non-generator in a Zip Generator | ||
----------------- | ||
|
@@ -169,7 +170,7 @@ possible to catch such an error at compile-time, this error is caught by | |
the Erlang linter. | ||
|
||
For example, the zip generator in the following comprehension contains a | ||
non-generator. | ||
filter. | ||
|
||
zip() -> [{X,Y} || X <- [1,2,3] && Y <- [1,2,3] && X > 0]. | ||
|
||
|
@@ -180,7 +181,6 @@ allowed in a zip generator, together with the position of the non-generator. | |
% 6| zip() -> [{X,Y} || X <- [1,2,3] && Y <- [1,2,3] && X > 0]. | ||
% | ^ | ||
|
||
|
||
Backwards Compatibility | ||
======================== | ||
|
||
|
@@ -190,7 +190,7 @@ this addition. | |
Reference Implementation | ||
======================== | ||
|
||
[Git Branch][1] contains the implementation for zip generators. | ||
[Git Branch][1] contains the implementation for zip generators. | ||
|
||
[1]: https://github.com/lucioleKi/otp/tree/isabell/compiler/zip-comprehension/OTP-19184 | ||
[2]: https://downloads.haskell.org/~ghc/5.00/docs/set/parallel-list-comprehensions.html | ||
|