Support default values
- Dominant language
- Python
- Stars
- 92
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
Reading an unset field through the Emboss view API results in an assertion error on non-debug builds. This is because we are reading uninitialized memory. It would be great if Emboss could support default values for certain fields.
**Use Case**
Consider packets which have opcodes in their headers. These opcode values are unique to the packet/message being constructed and never change. They need to be defined in the packet but having the developer fill them out every time is redundant and error prone. Instead, it would be better to define the value in the `.emb` file and have Emboss take care of it for all uses.
**Potential Implementation**
Specify a `[default: 0]` attribute in the `.emb` files. Fields are initialized to their defaults via an initialize() method on views.
Contributor guide
Assessment
This issue has not been assessed yet.