OskarS
Joined 10 years ago
Joined 10 years ago
If the nutso president of Turkmenistan decided one day that the Caspian Sea's real name was the Turkmen Sea, there's absolutely no way that Google Maps would rename it on their maps. The reason they renamed it in this case is not because "well, the government said so, so we have no choice!". It's (obviously!) done to not piss of Trump, and pissing off Trump would be bad for their business. They can hide behind lawyerly arguing all they want, but that is the real reason.
std::variant has a similar issue with valueless_after_exception, which given the semantics of the language, it has to have. But similarly, this essentially never happens in practice, and I've never encountered a bug with a valueless std::variant.
No, it has something much worse, it has a memory leak. The nested types inside the union allocate memory, and they don't get destructed when Event gets destructed. Don't do this in modern C++, it's a terrible terrible idea, these kinds of constructs are very hard to get correct manually. Just use std::variant.
Tagged unions (especially with resource-managing types) is hard to implement correctly in C++ (and not trivial in C either). Don't do it, use std::variant.
This is wildly overstating it. Yeah, I agree, they're much less often the right choice compared to a good-ol' growable array, but they have lots of uses in high-performance code and concurrent code, and they're building blocks in lots of other data structures. Like, in a bucket hash-table, the buckets are linked lists, in a LRU cache you interleave a hash table and linked list, std::hive is a linked list of chunks of elements, etc. Anything that has ever had to deal with memory pooling/allocation uses free-lists which are linked lists. And on and on and on.
The argument at the time was that no "native" Swedish words are spelled with a W, so it shouldn't be part of our alphabet. However, but 2006, enough loan-words had been imported to Swedish with W's (like "webben", "the web") and it was in enough brand names (like "Volkswagen") that it should be included.
But I'm still mad about it! This is my tiny ridiculous hill to die on, W should not be part of the Swedish alphabet!
I will say before testing this i didn't realize the RVO calling convention was to return the pointer you pass in, but apparently so. If makeS2() returned void, it's just a tail call to the constructor, but makeS1() has to spill rbx and use it to save the pointer.
SQLite recommends against doing that [1] while a transaction is active, because the copy might have some pre/post data in it which could potentially cause corruption. Presumably this isn't an issue with copy-on-write filesystems assuming they copy atomically, but I probably still wouldn't do it, instead use the backup API or VACUUM INTO (if nothing else, because VACUUM INTO will also obviously VACUUM the copy).
If you're not attached/writing to it, then of course it's fine.
[1]: https://www.sqlite.org/howtocorrupt.html#_backup_or_restore_...
Though fair enough, it could offer it as an opt-in thing.
You're correct in that the article is wrong in saying you can't use a nix repl this way, but I took the broader point of it to be "Nix-the-language gets in the way of the Nix-the-model". Which is something that I personally agree with 100% and I think the article illustrates beautifully.