Agreed regarding the "or" - rejecting consistency here just
because other languages do it differently is weird.
> it's not clear what it makes more succinct than the equivalent `elif` statements
But pattern matching is shorter than if-else in many cases and
can actually differentiate between structures which makes it
very flexible. It's like switch-case should have been from the
start imho.
As an example, in Rust I often do comparisons between certain
values by simply matching a tuple of them:
match (foo, bar) {
(x, x) => true, // foo == bar
(Foo::VariantA(42), _) => unreachable!(), // has to be a bug
(Foo::VariantA(a), _) => a < 0,
_ => false,
}
This is of course a rather simple example, but I hope it still
conveys what I like so much about this kind of feature. It
doesn't do more than an if-else chain, but under the right
circumstances it really shines. Just like list comprehensions
don't add any new functionality, but the filtering and mapping
features are often simply more expressive for what you want to
do.
Although I'm not sure what to think of Python's preference to
put the condition and code in different lines; maybe that's
optional, which could make it more succinct when the situation
permits it.
What does typed dispatch have to do with virtual functions in C++? This type of dispatch happens at compile-time in C++ and has nothing to do with "bloat" or even virtual functions.
I get the feeling that you don't know what virtual functions in C++ are.
I'd suggest you stop comparing typed dispatch to virtual functions in C++, because they have nothing in common. If you want to draw parallels, make sure to use a suitable analog.
Thanks ... I really appreciate the kind words. MIT Press has repeatedly tried to get me to do a 2nd edition and while it was tempting, I always ultimately decided that it was better to keep doing new things. Although, much to my surprise, a Japanese edition of the book just came out this year so there still seems to be some interest.
But that said, I am working on another book now that is meant to be a more accessible successor to CBofN and something of a computational "theory of everything else". I'm about halfway done, but the it's hard to write with the distraction of living in this bizarre timeline of ours.
Yikes! I guess I better finish it now. Although, you should prepare to be bitterly disappointed because the next book will have something to piss off almost everyone (not by design, it's just that simultaneously seeking breadth, depth, and readability will always fall short on at least on dimension).
FYI, I have no idea if I use tabs or spacves in my projects, my IDE is configured to use the popular linting/formatting so it autoformats using that,
Honest question, when you hit issues caused by someone else code not using your favorite style of tab vs spaces? Is there an editor/IDE that can't autodetect this and work properly or is there a language that would fail because is hyper sensitive to white space?
Which is why PEP-8 the Python code style guide enforces 4 spaces. This maintains consistency throughout the community. Also PyCharm one of the more popular IDEs for Python uses 4 spaces by default.
That's not what PEP-8 is for, it was meant to define the style of the standard libraries. A lot of people in the community voluntarily adopted it for their projects, but that wasn't its purpose.