Skip to content

Commit 3905144

Browse files
committed
Add note about weird filtering syntax to the readme.
1 parent 3027f17 commit 3905144

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,20 @@ parsing `key=val` pairs inside parentheses.
550550
`function (xs...) \n body end` parses the argument list as `(... xs)`, whereas
551551
`function (x) \n body end` parses the argument list as `(tuple x)`.
552552

553+
* The difference between multidimensional vs flattened iterators is subtle, and
554+
perhaps too syntactically permissive. For example,
555+
- `[(x,y) for x * in 1:10, y in 1:10]` is a multidimensional iterator
556+
- `[(x,y) for x * in 1:10 for y in 1:10]` is a flattened iterator
557+
- `[(x,y) for x in 1:10, y in 1:10 if y < x]` is a flattened iterator
558+
559+
It's this last case which seems problematic (why not *require* the second
560+
form as a more explicit way to indicate flattening?). It's not even pretty
561+
printed correctly:
562+
```
563+
julia> :([(x,y) for x in 1:10, y in 1:10 if y < x])
564+
:([(x, y) for $(Expr(:filter, :(y < x), :(x = 1:10), :(y = 1:10)))])
565+
```
566+
553567
# Comparisons to other packages
554568

555569
### Official Julia compiler

0 commit comments

Comments
 (0)