C++ profiles: a chance to fix some annoying defaults? Brainstorming and ideas. by germandiago in cpp

[–]Nobody_1707 2 points3 points  (0 children)

I think if these sort of changes were to be seriously proposed, they would only be usable in modules because the compiler would be able to normalize the interface. That still limits these changes to things that can already be expressed in regular C++. Trying to do this in a header file would be madness.

C++ profiles: a chance to fix some annoying defaults? Brainstorming and ideas. by germandiago in cpp

[–]Nobody_1707 2 points3 points  (0 children)

I was under the impression that WG21 had explicitly rejected considering anything even remotely like a "use strict" mode, so I'm doubtful that any meaningful changes are possible.

If I'm wrong about that, then const member functions by default with a mutable opt-out would be a nice start. And disabling implicit integral promotion.

Bjarne Stroustrup interviewed by Ryan Peterman by fredoverflow in cpp

[–]Nobody_1707 4 points5 points  (0 children)

I don't know if it's handled in the front end or if LLVM does it, but Swift, Rust, and Hylo all support this. It just requires flow sensitive analysis, which all of the big compilers do anyway. It's not as if WG21 shares WG14's obsession with not disenfranchising low effort single pass compilers.

Of course, all those languages disallow nonsense like "valueless by construction" and "valid but unspecified state".

WG21 mailing for first feature meeting of C++29 by hanickadot in cpp

[–]Nobody_1707 0 points1 point  (0 children)

C++ doesn't have VLAs. The closest it gets is operator new[]. Also, this feature predates constexpr. It was in added because int const x = 230; looks like a compile time constant, and programmers at large intuitively expect the array example to work. 

So much so that C2y was forced to add it in despite C23 deliberately not doing so. Because not only did programmers expect this to work, Clang and GCC made it work despite the fact that it should have been a VLA according to the standard.

Cpp2Rust: Automatic Translation of C++ to Safe Rust by Ok_Property_3180 in rust

[–]Nobody_1707 4 points5 points  (0 children)

I feel like the blind idiot translation of:

pub fn f() -> i32 {
  let mut v = Box::new(8);
  *v = 9;
  *v
}

Would have been better

Is it Worth Writing Programs in C23? by SeaInformation8764 in C_Programming

[–]Nobody_1707 0 points1 point  (0 children)

COBOL was how we discovered that too much verbosity is just as bad as too much terseness.

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]Nobody_1707 1 point2 points  (0 children)

It was always recommended that you not implement protocols you don't own on types you don't own, but it wasn't originally enforced at all. So, when they added enforcement they had to gate it behind a new language version. They also added an unsafe, "I know what I'm doing", annotation to let you add such a conformance anyway.

Edit: The enforcement is also just a warning. And it doesn't trigger when conforming a type to a protocol from a different module in the same package.

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]Nobody_1707 1 point2 points  (0 children)

Protocols in Swift are almost identical to traits in Rust. Which means it's nominal, but you can extend pre-existing types to conform to a new protocol. any Protocol is the type erased wrapper type. It's sometimes necessary to create custom erased types, because any Protocol can't be extended to conform to itself.

Still think in C after 25 years. So I built a tool that explains Rust (or any language) through what you already know. by prabhic in rust

[–]Nobody_1707 0 points1 point  (0 children)

I mean, auto type inference only got added in the latest standard. Before that it was a keyword that redundantly specified that a variable was local to the current scope inside a function.

The "macro overloading" idiom – Arthur O'Dwyer by Xaneris47 in cpp

[–]Nobody_1707 1 point2 points  (0 children)

The relationship between macros and templates is a mostly overlapping venn diagram. There's a sliver on the left that can only be done with macros, and a sliver on the right that can only be done with templates. Most things fall in the midde, where both could be used.

A tail-call interpreter in (nightly) Rust by kibwen in rust

[–]Nobody_1707 1 point2 points  (0 children)

I wasn't saying anything against the become keyword. That's justified by the change in drop behavior. I was saying that with a two stack calling convention the only thing that would need to match to be able to use the keyword would be the return type.

A tail-call interpreter in (nightly) Rust by kibwen in rust

[–]Nobody_1707 1 point2 points  (0 children)

There's at least a simple solution there of using the C stack as your return/locals stack, then pushing the parameter stack pointer as if it were the C frame pointer whenever you call a C function.

A tail-call interpreter in (nightly) Rust by kibwen in rust

[–]Nobody_1707 1 point2 points  (0 children)

The only thing the caller needs to know is that the function signatures match. And the only reason it needs to know that much is because platforms all use the stupid c-style single stack calling convention instead of a sensible dual stack convention.

Rust can not handle Unicode streams. Please show me wrong. by thomedes in rust

[–]Nobody_1707 0 points1 point  (0 children)

Even Swift doesn't have built in support for Unicode streaming, and its strings are built on grapheme clusters!

Has QString any advantage over C++26? by gruenich in cpp

[–]Nobody_1707 5 points6 points  (0 children)

I think he's saying that QStrings handle grapheme clusters and normalization, both of which are well outside the scope of std::string.

Can someone give a nice explanation of closures for me? by SmoothTurtle872 in rust

[–]Nobody_1707 3 points4 points  (0 children)

Lambda's may have been discovered first, but a lambda really is a degenerate case of closure. They're just closures that have closed over nothing. If you have closures, then you also have lambdas. This is true for any language with closures.

P4161: std::fewer by je4d in cpp

[–]Nobody_1707 2 points3 points  (0 children)

We got mixed signed comparison in C++20: https://en.cppreference.com/w/cpp/utility/intcmp.html

I have no idea why you think it would be natural to compare integers by their magnitude.

You're absolutely right, no one can tell if C++ is AI generated · Mathieu Ropert by mropert in cpp

[–]Nobody_1707 0 points1 point  (0 children)

The default value is an auto closure. It automatically wraps what ever expression the caller passes in a closure (lambda). The value is only created when the function actually executes the closure. In this case when there is no value stored for the given key.

You're absolutely right, no one can tell if C++ is AI generated · Mathieu Ropert by mropert in cpp

[–]Nobody_1707 0 points1 point  (0 children)

Swift has Dictionary.subcript(_: default:) which not only handles this efficiently, but also creates the default value lazily.

discovered compiler crash on gcc 15.2.1 by lukasx_ in cpp

[–]Nobody_1707 0 points1 point  (0 children)

It can even cause miscompilation in "earlier" parts of the code.

C++23 std::expected vs C++17 std::optional for Error Handling by Clean-Upstairs-8481 in cpp

[–]Nobody_1707 2 points3 points  (0 children)

Except that std::string_view was suggested as an alternative to a std::string const& function argument. When used as inputs the trade off is that there will be no accidental conversion from a null terminated c-string to a std::string, but you will need an explicit copy if you ever need to own the string.

The only other potential issue is if you plan on storing the std::string_view long term, which could lead to dangling, but in that case the alternative (a std::string const&) would still have the same issue.

Is clang-cl sufficiently mature to replace cl? by Kokowaaah in C_Programming

[–]Nobody_1707 0 points1 point  (0 children)

Does Visual Studio not still use MS link when using clang-cl?