mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Summary: Informal `DebugStringConvertible` interface serves the same purpose as `DebugStringConvertible` abstract class (providing universal pretty-printing interface) but relies on C++ static overloading instead of virtual dispatch. This approach has some advantages and disadvantages: Pros: * It's more clear and scoped. It's simpler to implement debug-printing functionality aside of normal production code. * It's more composable. * It allows print types that are not classes. * For some classes using `DebugStringConvertible` means that we have to use virtual inheritance (which might be undesirable and affect *production* performance (if a compiler isn't smart enough to remove empty base class). * For some highly lean classes (that designed to be as small as possible) adding base (even empty-in-prod) classes kinda... smells. Cons: The particular implementations cannot rely on dynamic dispatch which can complicate printing classes with meaningful differences between sampling classes (e.g. ShadowNode subclasses). That's why we don't remove `DebugStringConvertible` class yet. Reviewed By: mdvacca Differential Revision: D14715081 fbshipit-source-id: 1d397dbf81dc6d1dff0cc3f64ad09f10afe0085d