Not coalescing around None-aware
Not coalescing around None-aware
Posted Dec 28, 2022 9:22 UTC (Wed) by tialaramex (subscriber, #21167)Parent article: Not coalescing around None-aware
"None-aware operators" are a workaround for lacking Option / Maybe / the "... | None" ad hoc type.
Exceptions are a workaround for lacking Result / Expect
Languages should bite the bullet and provide Sum types even though that's a lot of work.
Posted Dec 28, 2022 21:55 UTC (Wed)
by NYKevin (subscriber, #129325)
[Link] (5 responses)
The real problem is that Python is dynamic, and "supporting Sum types" doesn't mean anything in the context of dynamic languages. Well, not unless you want to build some kind of wrapper object that really exists at runtime and can't be monomorphized away. But you don't need language-level support for that, you can Just Do It.
Posted Dec 29, 2022 2:21 UTC (Thu)
by tialaramex (subscriber, #21167)
[Link] (4 responses)
Posted Dec 29, 2022 8:20 UTC (Thu)
by smurf (subscriber, #17840)
[Link] (3 responses)
There are ways to declare interfaces for that kind of code; however, if you want to find typing problems statically instead of crashing on them, Python wants you to use a separate checker (like mypy).
Posted Dec 29, 2022 13:12 UTC (Thu)
by mathstuf (subscriber, #69389)
[Link]
Posted Dec 29, 2022 20:42 UTC (Thu)
by tialaramex (subscriber, #21167)
[Link] (1 responses)
This pollution has become pretty bad in C++ where on top of about 100 reserved words like "for" and "reinterpret_cast" and "co_await" there are a vast number of in practice unavailable identifier names which, if you make the mistake of using them, implicitly mark the affected type as having specific properties associated with that word e.g. cbegin() means you're able to provide a constant iterator, size() means you're some container with things inside it. Even though C++ doesn't "Have" duck typing in this respect in practice that's what it does.
Better, I am confident, to be able to state explicitly what you mean, if this Lyre Bird can in fact smurf::animal-noises::Dog::bark that's fine, but it shouldn't be confused with my tialaramex::army::DrillSergeant::bark which is provided neither by Lyre Birds nor Dogs. We need to be clear what is meant.
core::cmp::Ordering and core::sync::atomic::Ordering are both really, really important, but in their own context. Just because my sort method needs an Ordering and your spinlock code has an Ordering doesn't mean they're concerned with the same thing. If the two are in adjacent code, that code needs to spell out what's going on. In unrelated code, the expectation can be stated just once and then context is clear afterwards.
Posted Dec 29, 2022 21:56 UTC (Thu)
by mathstuf (subscriber, #69389)
[Link]
The mechanism of templating in C++ basically feels like it (since it feels a lot like "structured preprocessor" more than "provides interface"). Concepts should help, but standard library usage remains to be seen.
Not coalescing around None-aware
Not coalescing around None-aware
Not coalescing around None-aware
Not coalescing around None-aware
Not coalescing around None-aware
Not coalescing around None-aware