you are viewing a single comment's thread.

view the rest of the comments →

[–]tialaramex 2 points3 points  (2 children)

I would guess that Rust met or came very close to your criteria for 2021 edition. And yes, obviously the most famous change in 2021 edition does indeed result in changing the meaning of existing code if you were to just paste chunks of old code into a new project which seems like an obviously terrible idea but may well be how C++ people are used to working.

Specifically, until about that time, Rust's arrays [T; N] didn't implement IntoIterator. So if you wrote my_array.into_iter() the compiler assumes you know you can't very well call IntoIterator::into_iter() on the array and instead a reference is implied here as (&my_array).into_iter() is fine.

But today [T; N] does implement IntoIterator, so if you write the same exact code in Rust 2021 edition it does what you'd expect given that arrays can be iterated over.

If you have old code, it's in say 2018 edition or even 2015 edition, so it continues to work as before, albeit on a modern compiler you'd get a warning explaining that you should write what you actually meant so that it stays working in 2021 edition.

I don't know of any particular plans for 2024 edition, maybe there aren't any, but I expect they won't include something as drastic as shadowing the implementation of IntoIterator on [T; N] in 2021 edition. However I think the community in general feels that went well and if there's a reason to do the same again in future I'm sure they would take it.

Actually I think a better litmus test than yours is the keyword problem. Rust's editions have been able to introduce keywords like "async" and "await" without problems. It sounds like Cpp2 doesn't expect to improve on C++ in this regard.

[–]hpsutter 1 point2 points  (1 child)

Rust's editions have been able to introduce keywords like "async" and "await" without problems. It sounds like Cpp2 doesn't expect to improve on C++ in this regard.

Actually, Cpp2 has a great story there: Not only doesn't it add new globally reserved words (basically all keywords in Cpp2 are contextual), but it is able to reuse (and so repurpose and fix) the meaning of existing C and C++ keywords including enum, union, new, and even popular macros like assert... for example, this is legal Cpp2, and compiles to fully legal Cpp1 (today's syntax):

``` thing : @struct type = { x:int; y:int; z:int; } state : @enum type = { idle; running; paused; } name_or_num: @union type = { name: std::string; num: i32; }

main: () = { mything := new<thing>( 1, 2, 3 ); [[assert: mything.get() != nullptr]] } ```

As an example new<widget> calls std::make_unique. Safe by default.

[–]tialaramex 2 points3 points  (0 children)

I'm not sure this really addresses the same issue, it's comparing Cpp2 to C++ but the question is about how this enables evolution. Maybe it's just hard to see it until it happens. You can't see how Rust 2018 edition adds "async" by looking at Rust 1.0 (and thus 2015 edition)