Better HN
topnewbestaskshowjobs
Log inSign up

alvarelle

50 karma · joined Jan 30, 2020 (6y ago) · 27 submissions

Submissions

comment 5y ago · link · parent

> in rust as long as you don't use a feature you don't need to know about it.

Is that not the same in C++ and in most languages?

... until someone else in your team uses it in your code base. And then you need to know about it in Rust as well.

comment 5y ago · link · parent

Yes. That's orthogonal. And people have been using CMake with Qt (and moc) for almost as long as cmake exists

comment 5y ago · link · parent

You should be fine with the LGPL license of Qt.

comment 5y ago · link · parent

> ... std::atomic<bool>. This tells the compiler not to elide reads and writes of this variable, ...

If I'm not mistaken, this is not true. The compiler is still allowed to elide reads and writes on atomic variables. (For example merge two consecutive writes, or remove unused reads)

comment 6y ago · link · parent

I find it ironic that you answer to a comment asking for links, but you don't provide any. (Same for the other comments in this thread)

comment 6y ago · link · parent

I believe I understand correctly UB and unsafe.

The cxx crate and the autocxx tool should make sure that the exposed C++ functions only take arguments types which have well defined semantics.

In your example, a rust Box<T> maps to a rust::Box<T> in C++, which cannot be null. And a unique_ptr from C++ maps to a cxx::UniquePtr in rust which can be empty.

If somehow the C++ code puts a dangling or null pointer into a rust::Box, that is clearly a bug in the C++ code.

comment 6y ago · link · parent

The point is that the C++ code should be safe because the C++ programmer should not introduce UB on its C++ code. If the C++ code invoke UB, that is a bug in the C++ code which should be found by reviewing the C++ code alone.

No need to write 'unsafe' because .cpp files are already known to need carefull review.

comment 6y ago · link · parent

Imagine what proponents to heliocentrism such as Galileo had to face explaining their theory and how it explain a simplified elliptic orbit for the planets rather than the strange curly orbits known by geocentrists.

They'd be confronted with basic question from the audience: Why would things fall down if it was not the center? (That was before Newton) Wouldn't we see paralax in the stars (stars are much further away than what was believed at the time). Wouldn't we feel it if earth turns so fast? "Maybe that explains the tides" said Galileo (but it doesn't)

The previous model was also explaining the observations quite well at the time. Why should we care for another theory? (God works in mysterious ways.)

I'm not saying that MOND is correct. ("they also laughed at Bozo the Clown".) Just that the fact that there are some unexplained missing piece does not mean one should reject it so quickly.

comment 6y ago · link · parent

I did not see digraphs mentioned. Could look like <: and :>.

The formatting tool could even normalize that to some prettier unicode.

comment 6y ago · link · parent

The graphical design of his website?

comment 6y ago · link · parent

What's magic in Box?

comment 6y ago · link · parent

I believe you got it backwards. The price of bitcoin determines how much the miners are going to spend to produce it.

(Or we are both wrong)

comment 6y ago · link · parent

Could also try to use the smallvec crate in this case, which put small allocation on the stack https://docs.rs/smallvec/

comment 6y ago · link · parent

But with rust you have to re-learn the language every six weeks as it changes so fast. (/s)

comment 6y ago · link · parent

No, it hasn't.

Actually C++20 comes with only the minimal support for coroutines in the std library. If you want to do anything useful, you need to implement a promise type yourself which is very hard to do without using one library that does that.

comment 6y ago · link · parent

I don't know about the others, but C++ don't have a default implementation as part of the standard. If you want an event loop, you need to use one of the many libraries that provide one.

comment 6y ago · link · parent

I have a laptop I bought in 2009. I installed archlinux when I got it and upgraded regularly, and it still works.

comment 6y ago · link · parent

> Can anyone elaborate why exactly allowing demonstrably harmful and malicious lies [...]

"Contradicting WHO" is not the same as "demonstrably harmful and malicious lies"

comment 6y ago · link · parent

> Who decides who the liars, cranks and con artists are?

Yes, WHO decides.

comment 6y ago · link · parent

The article also suggests you should start with the post expensive option (60 in your case)

comment 6y ago · link · parent

Romans needed many more than 3 "digit" (or rather letter) to represent this date. Also, the AD system (counting the year since the birth of Jesus Christ) was introduced much later.

comment 6y ago · link · parent

Personally, I stick with K&R C. I haven't gotten around to update all my with function signatures. whats is the thing with putting (void) all over or specifying the return type of my functions? Really, these explicit function declaration are just code duplication that serious programmers don't need as they know their code. (/s)

comment 6y ago · link · parent

On the other hand, you could argue that the r# gives you "more prominence" which is exactly the stated goal of using that macro.

comment 6y ago · link · parent

Or using this crate: https://docs.rs/cpp/0.5.4/cpp/

comment 6y ago · link · parent

In C++ you can't hide a variable with another of the same name in the same scope. So you'd want to give different names to all the 'state' variables.

comment 6y ago · link · parent

That's assuming players knows about the other players, which is not specified in the problem description. It is not even specified if the same game is played several time with the same rules.

Given the description from the article:

> Suppose you're on a game show, > and you're given the choice of > three doors: Behind one door is > a car; behind the others, goats. > You pick a door, say No. 1, and > the host, who knows what's behind > the doors, opens another door, > say No. 3, which has a goat. He > then says to you, "Do you want > to pick door No. 2?" Is it to > your advantage to switch your > choice?

I'd say, no, it is not to my advantage because I'd think the host would only ask me to switch if I had taken the "right" choice and want to make me lose. Unless I knew that the host always ask if one wants to change, in which case the paradox indeed apply.

comment 6y ago · link · parent

If the host knows where the car is, why would it ask the player to change door if he knows the player already choose a goat? The problem should specify that those are the rules of the game that the host always open a door.

Otherwise, as a host, I would only offer the players to change if they picked the car. (And if they heard about this paradox before, they might even change their choice)