I agree that "purity" is rather hard to ensure and probably not needed, more 
like a safeguard against bad code.

I think main benefit is semantics: in Elixir it is single block and only 3 
(presumably) operations are allowed:

  * New variable iteration (Cartesian product style)
  * Variable assignment
  * Condition (if `false` then stop and begin new iteration)



When there are more allowed operations it also complicates the reading in the 
sense that one cannot read top-to-bottom because we should also account for 
mid-level else-branches, mutating variables (something with `var`). And when 
this complexity is present it really stops being "list comprehension" and more 
like a shortcut for several symbols: 
    
    
    rs = @[]  # replace with `collect(newSeq)`
    for ...
      ...
      rs.add n  # yay we can omit `rs.add`
    
    
    Run

I understand that distinction is subtle but I would agree that "cleaner" style 
of more restrictive set of operations and single indentation level lead to 
better code. I also understand that in Python and Elixir list comprehension is 
implemented as a language construct compared to our user-space macro and hence 
the trade-offs can be reasonable.

Reply via email to