3 ms·
How would this hypothetical syntax differ from the walrus operator? I.e. what is hard to understand with the walrus operator that wouldn't be with this new hypo
by Sean1708 7y ago
How would this hypothetical syntax differ from the walrus operator? I.e. what is hard to understand with the walrus operator that wouldn't be with this new hypothetical syntax and why?
- xg15 7y agoI think it could avoid cases where you "abuse" the walrus operator and make code harder to understand than necessary. E.g. things like: if (value := func()) and another_condition: ... Or: if another_condition or (value := func()): ... Or: x=1 my_list = [x := x+1, x := x-1] etc.
- Sean1708 7y agoAh ok, so you'd essentially allow it in fewer contexts? I would definitely have supported that, although I do think combining walrus with other boolean expressions in if and while is super useful and not particularly hard to understand.