Open sgmihai opened 1 year ago
On second thought, there are cases where one might want to initialize the object with different default values than the ones used for assertions. I believe there should be some special syntax to allow defining default values. Nim also recently got support merged for default value in objects: https://github.com/nim-lang/Nim/pull/20480
Sounds like a useful feature. My only concern is that, this essentially it requires extra codegen - some kind of initializer proc. I don't want to bloat codegen with something like this, because most people will probably not need it, but binarylang will still generate it for every single parser definition.
The next big planned change for binarylang is to split codegen into loosely-coupled components, and allow the used to configure which components to use. Once this component-based system is implemented, this feature can be a separate component.
Update: Binarylang now supports plugins as a parser option, so this feature can be implemented as such.
For expresiveness and consistency, it would be nice to use the binarylang's data structure definitions, to define outgoing only data in a network protocol, that does not need to be parsed in any way, just serialized. We can do this, but the object variable still has to be initialized with the values we want, and thus the assertion expressions are just comsetic in this example. I'd like to be able to do something like