167. Kona, C++26, Contracts, Reflection, Cpp2

With Gianluca Delfino and other colleagues. Reddit thread.

Media

Video

https://youtu.be/_KYUUc6LJR8

Podcast

https://redcircle.com/shows/0835997e-47ec-438e-b6ae-0b390966aa7e/episodes/0d1daf37-44c9-4242-9c33-d0fecb58f352

Powered by RedCircle

WG21 Kona meeting, November 2023

From Twitter:

WG21 meeting in Kona is over. SG21 approved our paper with a new Contracts syntax: https://wg21.link/p2961r2

The double square brackets are gone, contract checks are now spelled like this:

int f(int x)
  pre (x > 0)
  post (r: r > x)
{
  contract_assert(i > 0);
  return x + i;
}

The natural syntax has won apparently, but contract_assert, seriously? Reddit thread on a possible solution.

From Herb Sutter’s talk:

sutter cppcon23 0001

The attribute-like syntax would have stood out better IMHO, but whatever. As long as Contracts are in C++26…​

Also: REFLECTION!

Pattern matching: current target is C++29! <sadface>

From Inbal Levy’s Reddit post comments:

P2971R1: Implication for C++ "There was mild opposition and many neutrals, but also significant interest from a small but vocal set of people." Ok vocal minority, return with your next proposal, but just don’t steal ⇒ for your niche purpose rather than something more valuable and common like a terse lambda many have asked for (and many more have asked for that than have ever asked for implication).

Hear hear!

WG21 October mailing

Link

Paper: std::optional<T&>

P2988R0 by Steve Downey and Peter Sommerlad

We propose to fix a hole intentionally left in std::optional: An optional over a reference such that the post condition on assignment is independent of the engaged state, always producing a rebound reference, and assigning a U to a T is disallowed by static_assert if a U can not be bound to a T&.

Paper: Unified function call syntax (UFCS)

P3021R0 by Herb Sutter

Paper: C++ Should Be C++

P3023R0 by David Sankel (Adobe)

Video: Bjarne Stroustrup - Delivering Safe C++ (CppCon 2023)

A new iteration of the talk discussed previously.

https://youtu.be/I8UvQKvOSSw

Reddit

Concrete suggestions for initial Profiles, by Bjarne Stroustrup

Video: Herb Sutter - Cooperative C++ Evolution - Toward a TypeScript for C++ (CppCon 2023)

https://youtu.be/8U3hl8XMm8c

Follow-up post on Herb’s blog

"Safety for C++ 50x, simplicity for C++ 10x". Round numbers in slogans are a red flag for me, but OK.

Asking the audience: "How many of you would be interested in seeing C++ get significantly simpler and type/memory safer?" is a bit cheap. I’m not a fan of this style of presentation. Especially given that Herb’s "solution" is not actually C++ as such.

That Beetles song again, <eyeroll>. "All you need is class". jfc

"This is pure 100% C++." Proceeds to show non-C++ code, often invoking Bjarne’s name for validation (?).

"Swift is a TypeScript for Objective-C" — WHAT.

Says it’s just a personal experiment, then tells the audience that "the TypeScript way" (Cpp2) is the only way forward for C++ "because people are telling us gradual evolution is not good enough".

Sorry, I shouldn’t be so pessimistic and cynical. It’s easy to criticise without doing the actual work. Cpp2 could be our future. Or Herb could be trailblazing actual new C++ features, like the above UFCS.

But the whole talk feels like an ad.

Reddit

Stroustrup’s keynote - specifically the last point in the slide where it mentions that successor languages are welcome, but they’re not C++ is relevant here. No matter how much you try and sugarcoat it as a "TypeScript for C++".

How are you doing?

how are you doing

Of course, the proper British way is to always reply, "I’m good, thanks".