You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I am looking at is mapping the CDDL to my source code. Choices can currently be expressed in different forms with different syntax.
And it looks to me CDDL is more orienting towards CBOR validation rather than CBOR description. Am I right? Is it intented?
Here are examples from the current CDDL specification:
To clean it, first I will remove the choice define as a group (used by basecolors in the examples). The CDDL spec defines groups in the context of map or array. While the example basecolors would not have a sense at all in the context of map or array. If you want to keep the syntax, we could use =&(...) to always define "complex" choice.
While the example attire and protocol are only defined for CBOR data validation, the other examples are more used to structure CBOR data.
My suggestion would be to redefine the "choice" definition and have only two types of choices:
the (validation) choice mainly uses for CBOR data validation. The syntax choice1 / choice2 / ... could be kept
the named choice mainly uses for CBOR data representation. The named choice would cover all other choices and would require an annoted name for each entry. The name would not be used in the CBOR representation. The syntax |name1: choice1 | name2: choice2 | ... | could be used to represent named choice (| is often used to represent or operation in programming language).
CDDL is in wide use in a number of SDOs at this point and has already been used in a number of RFCs. Proposals to make major changes its syntax would need to meet a very high bar now.
As of today, the cddl tool contains a basic mechanism to extract C code (in the form of #define statements). There is no attempt to map group choices to union structures, but I don't see why this would be impossible with the current syntax.
What I am looking at is mapping the CDDL to my source code. Choices can currently be expressed in different forms with different syntax.
And it looks to me CDDL is more orienting towards CBOR validation rather than CBOR description. Am I right? Is it intented?
Here are examples from the current CDDL specification:
To clean it, first I will remove the choice define as a group (used by
basecolors
in the examples). The CDDL spec definesgroups
in the context ofmap
orarray
. While the examplebasecolors
would not have a sense at all in the context ofmap
orarray
. If you want to keep the syntax, we could use=&(...)
to always define "complex" choice.While the example
attire
andprotocol
are only defined for CBOR data validation, the other examples are more used to structure CBOR data.My suggestion would be to redefine the "choice" definition and have only two types of choices:
choice1 / choice2 / ...
could be kept|name1: choice1 | name2: choice2 | ... |
could be used to represent named choice (|
is often used to representor
operation in programming language).So the examples above would be converted into:
Using this syntax I would easily link these definitions to my source code. For instance in C, I would have:
Using the current CDDL syntax, it is impossible to link group choice to source code. And it makes hard to maintain the changes.
The text was updated successfully, but these errors were encountered: