News for hackers. Stuff that matters.
Re:C++23: The Next C++ Standard by nuancebydefault on Tuesday July 11, 2023 @12:50PM (#36683678)
That about wanting to change mind... it touches a string! Somehow the let-downs must have been too much for me at a certain point in time. That being said, I'm curious to find out right now. Edit... no such thing found as string interpolation in cpp, at least not in my first 4 search hits. I'll crawl back.
Re:C++23: The Next C++ Standard by Conscat on Tuesday July 11, 2023 @01:03PM (#36683891)
String interpolation is currently blocked by:

- template-function parameters (NTTPs with a function parameter syntax rather than a template parameter syntax, tentatively spelled as `void foo(template int constant){}` )

- Scalable reflection, in combination with expansion statements (likely in C++26, spelled `template for (auto& e : array) {}` ) which would allow you to write an arbitrary parser for the template string into real C++ code.

Syntax2 already supports string interpolation as a special compiler feature.

Re:C++23: The Next C++ Standard by coldtea on Tuesday July 11, 2023 @01:12PM (#36683999)
std::string formatted_str = std::format( "My name is {} and my favorite number is {}", name, num);
Re:C++23: The Next C++ Standard by 0xffff2 on Tuesday July 11, 2023 @01:17PM (#36684085)
That's really nothing like python strings, which for the same string would be

    formatted_str = f"My name is {name} and my favorite number is {num}"
The function call I could forgive, but the the ability to embed arbitrary python expressions into the f-string directly is a huge readability win IMO.
Re:C++23: The Next C++ Standard by interroboink on Tuesday July 11, 2023 @01:41PM (#36684488)
Meanwhile Perl's over here like "we had this in the 90s!" (:
Re:C++23: The Next C++ Standard by gpderetta on Tuesday July 11, 2023 @02:42PM (#36685435)
Of course posix shells gad that even before. How far we can go? What's the first language that had something that resembles string interpolation?
Re:C++23: The Next C++ Standard by interroboink on Tuesday July 11, 2023 @02:55PM (#36685643)
I'm sure someone here can say something about Lisp machines (:
Re:C++23: The Next C++ Standard by coldtea on Tuesday July 11, 2023 @07:51PM (#36688708)
Well, if that's the syntax, I'd rather not have it!
Re:C++23: The Next C++ Standard by coldtea on Tuesday July 11, 2023 @07:50PM (#36688704)
That type of interpolation is something most non-scripting languages don't have anyway, and it took Python several decades to get it, and only has had it in the 5 years or so.