|
|
|
|
|
by necovek
38 days ago
|
|
It is focused on communication flow for small data-only loops: it is much easier to reason about items = [ this for iterator ]
because you immediatelly see what type of data ends up in `items`. Syntax inversion overhead is very much paid for with this benefit IMO.Again the bigger problem is the 'if', including in comprehensions. |
|
But that's simply not true at all.
Let's start with token by token:
You have no clue what type of data ends up in `items`, or that something should end up in `items` at all. This is obvious. You have no clue what type of data ends up in `items`. You just know now, that something will end up there. You only know that a list will be in `items`. Not what will be in the list. You only know that a list will be in `items`. Not what will be in the list. You have no clue what is `this`. You only know that a list will be in `items`. Not what will be in the list. You have no clue what is `this`. You only know that a list will be in `items`. Not what will be in the list. You have no clue what is `this`. You cannot have, or you break the right to left propagation with nested cases, against what you have with this simple example of yours. This is the only time when you know what type is `items` or `this`.Also `this` is a useless identifier, if you cannot transform or filter in your list comprehension. I don't like mine either that it contains pointless words...
Don't get me wrong, your example is clearly a right to left data flow. Which is not inherently bad, because `items` and `this` are new identifiers, which won't figure out by IDEs, so it doesn't matter.
Also, in my example of Python code (not my version of it, but the valid Python code), there is no need to have `if` at all to break intellisense, or break either left to right or right to left data flow several times inside the list comprehension.