Re:What Is Rust's Hole Purpose?
by stonemetal12 on Friday February 18, 2022 @01:41PM
(#30389436)
To be fair C++ is backwards compatible with C. That meant there was a large amount of design space they couldn't explore. Rust not going there gave them the ability to do better.
[ Parent
| on HN ]
Re:What Is Rust's Hole Purpose?
by tialaramex on Friday February 18, 2022 @06:35PM
(#30392675)
That intent to be "backwards compatible with C" doesn't stretch so far as to say, provide any way to spell valid symbols from C.
Imagine you have some C that has (for whatever reason) named two important functions "class" and "fn" which are completely reasonable C symbol names. In C++ that word "class" is reserved, so you can't name symbols class, but, that is what the C symbol's name is so too bad? However in Rust, even though fn is a reserved word there's no problem referring to that symbol, you just have to spell it r#fn meaning "the symbol named fn" as distinct from the keyword fn.
Re:What Is Rust's Hole Purpose?
by rwaksmunski on Friday February 18, 2022 @06:50PM
(#30392817)
C++ is no longer backwards compatible with modern C.
C++ compatibility has improved. E.g. I've noticed that C++20 has designated initializers for struct members, which were introduced in C99. So now if you're writing C that has to compile as C++, you can use C99 designated initializers, if you're OK with requiring C++20.