How to make your replacement for a C language Google-able: name it after an API for a C language: Carbon was one of two primary C-based application programming interfaces (APIs) developed by Apple for the macOS (formerly Mac OS X and OS X) operating system. Compare also keywords or key terms: Carbon will be built on a foundation on modern programming principles, including a generics system, that would remove the need…
Since “C++” reads like a Carbon ion with two positive charges, they could have called it “Cation”.
Google Launches Carbon, an Experimental Replacement for C++
241–243 of 243 posts
Re: Google Launches Carbon, an Experimental Replacement for C++
#242Earlier quoted context omitted.
Why are classes automatically somehow assumed as complex? Rust's structs are basically classes without class inheritance.
Dealing with inheritance is pretty complex!
Re: Google Launches Carbon, an Experimental Replacement for C++
#243Earlier quoted context omitted.
> In Rust, moves are destructive (which simplifies implementions - you don't need an "empty" state) and always bitwise (which is usually fine, so long as they're destructive); and copies are always explicit so you don't have the above problem. Rust has implicit copies too, e.g. if you do: let v = 2u16; foo(v); then v is being copied. What Rust does not have is implicit deep copies. The auto-copying depends on the typ…
In Rust, types implement the Copy trait and the Drop (destructor) trait independently. Vec could easily implement Copy. It doesn't because copying a Vec requires an expensive heap allocation, which can surprise users when it happens implicitly.
struct Foo;
impl Copy for Foo {}
impl Drop for Foo {
fn drop(&mut self) {
// ...
}
}
It gives the error: error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor
--> src/main.rs:3:1
|
3 | impl Copy for Foo {}
| ^^^^^^^^^^^^^^^^^^^^ `Copy` not allowed on types with destructors
See also the "When can't my type be Copy?" section of the Rust documentation: https://doc.rust-lang.org/1.62.0/std/marker/trait.Copy.html#...