FIXTradingCommunity / fix-simple-binary-encoding

A FIX standard for binary message encoding
Other
261 stars 69 forks source link

Can `<field>` override presence of its type? #155

Closed OleksandrKvl closed 2 years ago

OleksandrKvl commented 2 years ago

This is a generalization of unanswered #153. Documentation says that <field> inherits presence from its type but it doesn't say if or when it can be overridden. I believe documentation is a bit wrong because it says that the default value for presence is required, however looks like this can be true only if a field is of a built-in type, in all other cases presence by default is inherited from a custom type.

Here's a couple of tricky cases:

Current design feels like field was not intended to introduce new types, only reuse them. Because of that I think that the right way is to allow field to have presence only for built-in types. For all other cases it should be inherited (and can't be overridden) from type itself.

Please clarify how it should work.

donmendelson commented 2 years ago

The inheritance of attributes from elements to was a feature of SBE v1.0, but it was eliminated in v2.x because it was deemed confusing. In the v2.x schema, presence attribute is only used on <field> and the members of a composite type.

Nevertheless, v1.0 specification states that "presence mismatch" is an error. If the attribute is specified on both a field and the encoding that it references, the values must be identical.

Current design feels like field was not intended to introduce new types, only reuse them. Agree.

Because of that I think that the right way is to allow field to have presence only for built-in types. "built-in" is not a term used by the specification. Perhaps you mean primitives.

OleksandrKvl commented 2 years ago

Thank you!