-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offsets should not be allowed in expressions #640
Comments
I fully support the idea to not use offsets in expressions at all. I can not think of any meaningful use case that would require this. In addition I want to drop an idea:
Any |
What about offset arrays?
What should zserio return before writing? Is an empty array ok? |
Actually, the requirement that during writing the offsets should be initialized correctly and automatically together with no setters is very strict. Consider this:
To calculate automatically the size of If we need such strict requirement which it probably makes sense from the user point view, we must be very strict in the usage of the offsets:
Putting all together, we must implement a huge restrictions for usage of offsets at the beginning if we want to improve usability. This could potentially break some schemas but we probably might to afford it together with change of the documentation that such usage of offsets is illegal. Regarding new |
I was thinking about using
I guess empty array would be OK. |
Actually, |
Ah... I see... makes sense. |
Then we could even skip the
or yet better:
|
Dedicated Offset Types: I support the idea of explicit types and don't see a problem with having different variants. @mikir, why do you think this could be too complicated? Are there implementation concerns? Users need to choose the offset field size anyway. We also need to consider backward compatibility. Using plain numeric types could generate a warning like, "Using offset fields with plain numeric fields like uint32 is not recommended; use offset32 instead." Improved Syntax: I like the improved syntax suggestion. For compatibility,
This way, it's clear at first glance whether it's an offset to the |
Actually, I had two minor things in my mind:
As you pointed out, we have currently the same problems with offsets anyway, so probably this is not a big issue.
We should just check the abnormal usage:
|
Don't forget to update documentation with some more detailed description of the offsets. |
Consider the following schema:
Such schema is not possible to fill by data correctly. Consider how the
myOffset
will be calculated and what will happen during write and read operation.myOffset
will be initialized to0
.optionalValue
will be set to0
.myOffset
will be set to4
(4
bytes because ofuint32
type +0
because of optionaluint8
which is not there0 != 4
).myOffset == 4
,optionalValue = 0
,strigValue = "something"
.myOffset == 4
but it should5
because optional is suddenly there.We should reconsider usage of offsets:
One easy solution could be just to disable offsets in any Zserio expression.
Another solution could be that expressions with offsets can be used only after offset label. This is quite complicated and it is a question if this is usefull at all. For example, the following schema is ok:
The text was updated successfully, but these errors were encountered: