Loading…
C++Now 2018 has ended
Thursday, May 10 • 9:00am - 10:30am
yomm2: Fast, Orthogonal, Open Methods in a Library

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
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.

yomm2 is available on GitHub (https://github.com/jll63/yomm2)

Speakers
avatar for Jean-Louis Leroy

Jean-Louis Leroy

Senior Software Engineer, Bloomberg LP
I am the author of yomm2, a library that implements open multi-methods. See https://github.com/jll63/yomm2


Thursday May 10, 2018 9:00am - 10:30am MDT
Hudson Commons
  presentation