Pattern Matching: A Sneak Peek - Michael Park - CppCon 2019

preview_player
Показать описание


Pattern Matching: A Sneak Peek

Pattern matching brings a declarative approach to destructuring and inspecting complex data types. It’s a very powerful abstraction provided by many programming languages such as Haskell and OCaml, and more recently, Rust, Scala, and Swift.

The goal of the talk is to build an intuition for pattern matching, and gather feedback of the state of an early stage proposal.


Michael Park

I'm a software engineer at Facebook, working on the C++ libraries and standards team. My focus for C++ is to introduce pattern matching to facilitate better code.


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

I started learning C++ as my first programming language, but I also studied SML and Scala among others. I was shocked when Michael said that "about more than half the room" raised their hand, knowing the concept of pattern matching. Shouldn't the attendees at Cppcon be more familiar with programming paradigms in general? I loved the talk and hope this integrates well in C++.
How efficient would the variant type selection be compared to overloading and visiting?

araeos
Автор

[.value:0, .next: *? [.value:0]] - this is compilable Perl, i don't even want to read this code. I can, but I don't want to. I would rather expect pattern matching to make code more readable, not less readable.

otko
Автор

You should be able to use the dereferencing pattern with recursive pattern matching to make a pretty succinct finite state machine, and I suspect that this is exactly what they did in CTRE.

illeatmyhat
Автор

What are the chances to get this one in C++20? Are there any obstacles of getting this one into standard?

alex.syniakov
Автор

why inspect instead of "with"?


with constexpr {
as pattern : stmt;
as pattern: stmt; ...
}


would hint to what's going on to both Python-minded and Pascal-minded people. And that a wide spectrum of people. And shorter "with" and "as" would make nesting less cumbersome.

drd