HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

CppCon 2015: Andrei Alexandrescu “Declarative Control Flow"

CppCon2 HN recommenders · recommended in 2 months, 2016-2022
YouTube
102K views · 11 years ago · talk · evergreen

Andrei Alexandrescu's CppCon 2015 talk on handling exceptional control flow declaratively in C++. It uses scope guards with success and failure variants, built on std::uncaught_exceptions, to replace ad hoc RAII classes and rethrowing try/catch blocks.

Pointed to in threads on defer, scope_exit and RAII as the clearest treatment of scope guards.

C, C++, Rust, Go & systems languages#scopeguard#raii#uncaught_exceptions#cppcon#andreialexandrescu

5 comments from Hacker News

@einpoklum2022 · in “A Tour of C++ (Third edition)”

A count of the number of exceptions in-flight was added, replacing the boolean indication of whether an exception is in-flight. This allows the scope guard construct proposed by Andrei Alexandrescu to distinguish between a scope being left on success and on an exception being thrown. YouTube video about scope guard: ▶ this video Description of the change to the standard: link

CitesView on HN
@watmough2022 · in “Ask HN: What should have been the term for RAII?”

I think scope or similar is good. Also, see related video here CppCon 2015: Andrei Alexandrescu “Declarative Control Flow" ▶ this video

CitesView on HN
@dnautics2020 · in “A Defer Mechanism for C”

yes, you always run defer. I don't see it in this proposal, but Most languages/frameworks that implement a defer also implement a "error defer" which only gets triggered on some sort of labeled early exit scenario, and some implement "success defer": (i believe this is scopeguard: ▶ this video )

CitesView on HN
@uep2018 · in “Scope exit in C++11 (2012)”

Andrei Alexandrescu has a fun talk about implementing scope_exit using a new C++17 function: std::uncaught_exceptions (which is a tweak to std::uncaught_exception). Fundamentally, it doesn't really solve the destructor throwing exceptions issue though. ▶ this video

RecommendsView on HN
@Ace172016 · in “Memory management in C programs (2014)”

Google is an example that writing production code that doesn't use exceptions is possible, not that this is the right thing to do. They said that their decision was primarily legacy-motivated (in short, they were fearing that introducing exceptions in a non-RAII codebase would lead us to a long period of instability). I'll add that in some situations (e.g when freeing resources) the control flow gets very convoluted, and you don't want to deal with directly. See: Andrei Alexandrescu - Declarative Control Flow ( ▶ this video )

RecommendsView on HN
De-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable - Herb Sutter  CppCon 20191:33:12

De-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable - Herb Sutter CppCon 2019

CppCon
90K views • 7 years ago
CppCon 2016: Herb Sutter “Leak-Freedom in C++... By Default.”1:39:25

CppCon 2016: Herb Sutter “Leak-Freedom in C++... By Default.”

CppCon
149K views • 10 years ago
CppCon 2015: Andrei Alexandrescu “std::allocator...”1:12:27

CppCon 2015: Andrei Alexandrescu “std::allocator...”

CppCon
196K views • 11 years ago
CppCon 2015: Herb Sutter "Writing Good C++14... By Default"1:29:06

CppCon 2015: Herb Sutter "Writing Good C++14... By Default"

CppCon
193K views • 11 years ago
CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior..."57:39

CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior..."

CppCon
94K views • 10 years ago
C++ Exceptions for Smaller Firmware - Khalil Estell - CppCon 20241:24:36

C++ Exceptions for Smaller Firmware - Khalil Estell - CppCon 2024

CppCon
23K views • 1 year ago
Can C++ be 10x Simpler & Safer?  - Herb Sutter - CppCon 20221:54:00

Can C++ be 10x Simpler & Safer? - Herb Sutter - CppCon 2022

CppCon
277K views • 3 years ago
CppCon 2015: Bjarne Stroustrup “Writing Good C++14”1:40:46

CppCon 2015: Bjarne Stroustrup “Writing Good C++14”

CppCon
351K views • 11 years ago
CppCon 2017: Louis Brandy “Curiously Recurring C++ Bugs at Facebook”52:01

CppCon 2017: Louis Brandy “Curiously Recurring C++ Bugs at Facebook”

CppCon
158K views • 9 years ago
CppCon 2018: Nicolai Josuttis “The Nightmare of Initialization in C++”59:58

CppCon 2018: Nicolai Josuttis “The Nightmare of Initialization in C++”

CppCon
79K views • 8 years ago
CppCon 2017: Matt Godbolt “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”1:15:46

CppCon 2017: Matt Godbolt “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”

CppCon
178K views • 9 years ago
CppCon 2014: Herb Sutter "Back to the Basics! Essentials of Modern C++ Style"1:40:27

CppCon 2014: Herb Sutter "Back to the Basics! Essentials of Modern C++ Style"

CppCon
323K views • 12 years ago
The One-Decade Task: Putting std::atomic in CUDA. - Olivier Giroux - CppCon 20191:05:39

The One-Decade Task: Putting std::atomic in CUDA. - Olivier Giroux - CppCon 2019

CppCon
11K views • 7 years ago
CppCon 2019: Matt Godbolt “Path Tracing Three Ways: A Study of C++ Style”55:42

CppCon 2019: Matt Godbolt “Path Tracing Three Ways: A Study of C++ Style”

CppCon
77K views • 7 years ago
CppCon 2019: Matt Godbolt “Compiler Explorer: Behind The Scenes”1:00:21

CppCon 2019: Matt Godbolt “Compiler Explorer: Behind The Scenes”

CppCon
29K views • 7 years ago
Going Native 2012 Keynote Stroustrup1:29:49

Going Native 2012 Keynote Stroustrup

savage309
33K views • 14 years ago
CppCon 2017: Herb Sutter “Meta: Thoughts on generative C++”1:47:45

CppCon 2017: Herb Sutter “Meta: Thoughts on generative C++”

CppCon
105K views • 9 years ago
Sorting Algorithms: Speed Is Found In The Minds of People - Andrei Alexandrescu - CppCon 20191:29:55

Sorting Algorithms: Speed Is Found In The Minds of People - Andrei Alexandrescu - CppCon 2019

CppCon
184K views • 7 years ago
CppCon 2015: Sean Parent "Better Code: Data Structures"1:04:00

CppCon 2015: Sean Parent "Better Code: Data Structures"

CppCon
106K views • 11 years ago
'Fastware' - Andrei Alexandrescu [ ACCU 2016 ]1:02:17

'Fastware' - Andrei Alexandrescu [ ACCU 2016 ]

ACCU Conference
34K views • 10 years ago