922 karma · joined August 18, 2014
The following code prints 1, 2, 3. It wouldn't do that if the variable was captured by value.
for (let i = 0; i < 3;) {
setTimeout(() => console.log(i));
i++;
}Rust variable capture is implicit though, but it can't cause the problems described in the article, since mutable references are required to be unique.
> lexical scope is "the portion of source code in which a binding of a name with an entity applies".
...both `let` and `var` are lexically scoped, the scopes are just different.
You might want to step off that extremely high horse for a second, buddy. It's extremely reasonable to expect a type-safe pool that only holds a single type, since that's the most common use case.
You haven't looked very hard then, NodeJS has supported worker threads for years. However, to uphold Javascript's safety guarantees, they can only communicate via message passing, or sharing a special `SharedArrayBuffer` datatype, neither of which are well suited to sharing large immutable data structures.
Software never gets rewritten in a higher level language, but software is constantly replaced by alternatives. First example that comes to mind is Discord, an Electron app that immediately and permanently killed every other voice client on the market when it launched.
You can with Rust features. It allows a library to conditionally compile certain parts of the code, and users of the library can decide which features to enable.
If a library only uses stdlib in code gated by #[feature(std)], users can disable that flag, and use the library in no_std contexts.
Yes
> Does that sort of thing have to be considered when planning the orbits of probes etc?
Yes, it's a primary concern when sending probes to other planets
> Is Earth traveling fast enough, from the viewpoint of Alice floating near the sun, to have a gravity "tail" or "wake" trailing after it?
If I understand you correctly, then classically (i.e. ignoring relativity), no. Your gravitational acceleration towards the earth depends only your distance to it. If you consider general relativity? It's... complicated.
What in the world. In December, southern Norway had similar electricity prices for two hours, and caused enough of an uproar that the government is still trying to live it down.
I'm sure you could technically emulate all this in C++ is you keep throwing template metaprogramming at it, but at that point anything is a C++ subset and the statement loses all pratical meaning.
While this may work as a rough heuristic, it's not true in theory nor in practice. First example that comes to mind: Rust has proper sum types (Called enums), which are used everywhere, and C++ doesn't have anything like it.