4,901 karma · joined Sep 13, 2020 (6y ago) · 1,641 submissions
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
fn main() {
let x = [1, 2, 3];
println!("{:?}", x);
let y = x.map(|x| x % 2 == 0);
println!("{:?}", y);
}
x is borrowed by println (or rather by code that println expands to) and then it is moved by array::map. The compiler needs to know that before x.map(), x is not borrowed anymore. Otherwise it could be that println actually stored a reference to x somewhere and now you have a dangling reference possibly breaking type-safety (referring to an array of bools through a reference to array of ints, if the map is implemented as an in-place operation).comment 4y ago · link · parent
comment 4y ago · link · parent
Without the borrow checker, this "move-by-default, move is memcpy" semantics would break all hell loose. Dangling pointers/references would be everywhere. I like this part of Rust, but I'm not sure if it can work in a non-GC, no-borrow-checker language.
comment 4y ago · link · parent
Same here. I used to be in a team with daily stand-ups, reporting to the manager what work I did the day before, and they killed my will to work, consequently causing me to work ~3 times slower, which presumably is the opposite of the intended effect.
comment 4y ago · link · parent
I also looked at the "simple" Zig version, which came out really well in the benchmark, and to me it didn't look simple at all. It seems you need to make a lot of low level details explicit.
But IMHO AWK takes the crown here. :)
comment 4y ago · link · parent
But you can have a macro foo which expands to a generic selection: <https://docs.microsoft.com/en-us/cpp/c-language/generic-sele...>
comment 4y ago · link · parent
Recently, after a party where I drank alcohol, I concluded that I actually don't like the state alcohol puts me in. The slower reaction time, slower thinking, the need for preparation regarding eating and then after the fact drinking water before sleeping etc. Luckily I don't spill any secrets I shouldn't spill when I'm drunk, as some people do. I'm also the sort of person who gets annoyed at hot weather mainly due to its detrimental effect to the speed of my mind. It's just very unpleasant to me. So even though I don't have the slightest problem with alcohol (for a typical year I can count the number of times I drink alcohol on the fingers of a single hand, and no substance ever even began to take a hold over me), I've decided to quit it entirely, because I prefer to drink something as peasant as lemonade or tea, which doesn't inhibit my mind.
comment 4y ago · link · parent
int main () {
return
#embed "file.bin"
;
}
There are plenty of cases, where it will all behave differently. And if you're going to pretend even more that the preprocessor understands C syntax, then why not just give this job to compiler proper, which actually understands it?comment 4y ago · link · parent
comment 4y ago · link · parent
I heard about #embed, but I didn't hear about std::embed before. After looking at the proposal, to me it does look a lot better than #embed, because reading binary data and converting it to text, only to then convert it to binary again seems needlessly complex and wasteful. I also don't like that it extends the preprocessor, when IMHO the preprocessor should at worst be left as is, and at best be slowly deprecated in favour of features which compose well with C proper.
Going beyond the gut reaction and moving on to hard data, as you can expect from this design, std::embed of course is faster during compilation than #embed for bigger files (comparable for moderately-sized files, and a bit slower for tiny files).
I'm not a huge fan of C++, but the fact that C++ removed trigraphs in C++17 and that it's generally adding features replacing the preprocessor scores a point with me.
[1]: <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p10...>
comment 4y ago · link · parent
924.
Tell HN: You can't create a top folder named “Calendar” in Office365 Outlook
5 points · by yakubin · 4y ago · 1 comment
comment 4y ago · link · parent
I'm 25 and a couple weeks ago I discovered a new way to use a knife to prepare a fish, even though I've been doing that all my life. I don't think knives or fish have bad UX, even though I keep discovering new ways to use knives on fish. What's important is that I don't keep discovering new ways to hurt myself with knives.
comment 4y ago · link · parent