3 ms·
We should not optimize for the common case at the expense of making the uncommon case impossible. With C style switch, you can fall through or break. In langua
by toast0 7y ago
We should not optimize for the common case at the expense of making the uncommon case impossible.
With C style switch, you can fall through or break. In languages that don't provide fall through (say Erlang's case expression), if you have something that fits fall through, you need to either duplicate the inner code, or have a more verbose construction with multiple phases of matching.
- melling 7y agoSo, 99% of the time to need to be more verbose to handle the 1% case? I’d rather wrap the duplicate code in a function and call it in each instance.