filmov
tv
CppCon 2018: Jean-Louis Leroy “Open is Good - yomm2: Fast, Orthogonal Open Methods”

Показать описание
—
—
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.
Circa 2007, Pirkelbauer, Stroustrup and Solodkyy wrote several papers about open multi-methods methods for C++, but the idea has failed to gain acceptance so far. My yomm2 library provides an implementation that is both fast (close to virtual functions), elegant and non intrusive.
I will give a follow up to this talk, delving in the internals of yomm2, in an open session the next day (Wednesday, September 26) at 12:30.
—
Jean-Louis Leroy
Senior Software Engineer, Bloomberg LP
—
*-----*
*-----*
—
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.
Circa 2007, Pirkelbauer, Stroustrup and Solodkyy wrote several papers about open multi-methods methods for C++, but the idea has failed to gain acceptance so far. My yomm2 library provides an implementation that is both fast (close to virtual functions), elegant and non intrusive.
I will give a follow up to this talk, delving in the internals of yomm2, in an open session the next day (Wednesday, September 26) at 12:30.
—
Jean-Louis Leroy
Senior Software Engineer, Bloomberg LP
—
*-----*
*-----*
Комментарии