yomm2: Fast, Orthogonal, Open Methods in a Library - Jean-Louis Leroy - C++Now 2018
Channel: CppNow
Date: 2018-06-06

http://cppnow.org
—

yomm2: Fast, Orthogonal, Open Methods in a Library - Jean-Louis Leroy - C++Now 2018
Presentation Slides, PDFs, Source Code and other presenter materials are available at: http://cppnow.org/history/2018/talks/
—
yomm2 is available on GitHub (https://github.com/jll63/yomm2)

Have you ever felt your life would be simpler if you could just add virtual functions to a class hierarchy whenever you needed to (e.g., to persist an object or render it in JSON), but refrained because you did not own the classes and it would violate the principle of separation of concerns? Have you toiled on a Visitor class once again? Did you struggle to get double dispatch right because you needed to implement binary operations for polymorphic classes? 

Open methods solve all these problems, while requiring you to write much less code -- and they deliver superior performance. 

Open methods are virtual functions that are defined outside of a class. Given a method declaration and a set of specializations, the most specific version is selected depending on the dynamic type of one or more arguments. Open methods make it possible to add polymorphic behavior to existing hierarchies of classes, without needing to modify them. They provide a superior alternative to the Visitor pattern and a solution to the problem of cross-cutting concerns. Since more than one argument can participate in the selection of the specialization, open methods also solve the binary (or multiple) dispatch problem. 

yomm2 implements open methods in a library. Unlike its predecessor yomm11, it does not require instrumentation of the classes involved in method dispatch, yet calling a method with one virtual argument is almost as fast as calling the equivalent virtual member function. 
— 
Jean-Louis Leroy
Senior Software Engineer, Bloomberg LP
—
Videos Filmed & Edited by Bash Films: http://www.BashFilms.com
---

*--*

---