Open
Description
Is your feature request related to a problem? Please describe.
Currently bebop use concrete type when generating a field with non-scalar types. This make things simple since everything is value-based, but prevents user to make cyclic dependency which gracefully prevented in #111.
Describe the solution you'd like
I would like to suggest to revise and support cyclic dependency instead. Here what I had in mind:
- Define a custom
std::optional
implementation, but instead of use value type, use heap (e.g smart pointer). This is relatively simple to do. - Determine definitions that are cyclic in parser, and then in the generator, forward declare them before generating the actual definitions.
- The custom optional will incur extra cost in runtime; typically it use 4-8 bytes (the
std::optional
use extra 1 byte only) and it loss cache locality. Thus, this custom optional should only be used only for non-scalar type where the size is trivial
Describe alternatives you've considered
The easiest way (and relatively safe) to do this is to expose smart pointer for non-scalar type. But this would be a breaking change to the user.
Additional context
N/A
Activity