Introducing the BARE message encoding
@sir looks like untagged unions are not playing well with the first rust implementation.
@c_cube the unions are tagged, not untagged
@sir They're tagged in the wire format, but not in the IDL. Tagged unions would typically take an enum as a parameter and map each case to a message.
See for example zig: https://ziglang.org/documentation/master/#Tagged-union
@c_cube they're tagged in both. They don't have to have a separate enum to qualify
@sir I don't see a tag in `(a|b|c)`. I see an anonymous union where the order of declarations matters.
It's the same thing as removing `struct` (with named fields)` and replacing it with tuple syntax `(string, string, i32, bool, i64)` without names. Still technically a struct, but the code generated from that gives you accessors by position, not name, of fields.
By anonymous union, I think you mean that each item in the union is not given a name. This does not mean that the union is untagged. The difference between a tagged an untagged union is that tagged unions carry which item of the union they are, but untagged unions do not. The "tag" refers" to the data which determines the type, and not to the name given to the alternative.
In Zig, for example, a plain `union` is untagged, but if you simply add `union(enum)`, it becomes tagged. In both of those cases, each alternative is given a name.
So I agree that technically, BARE has tagged unions, but they should be tagged with enums, not integers. Again, same as structs having names, not just field numbers.
It would seem to me that struct field names have as little use as enum tag names (obviously, I'm on the opposite side of @c_cube here) since all the names are stripped away anyway. We can get by with just tuples and unions.
And its usage:
I think what you want can often be accomplished at the library level. A reasonable assumption is that the same type that was used to serialize the data can be used to deserialize the data. Thus, if the order of a Rust enum changes, then it will change during serialization and deserialization together, so everything will still work.
While I don't think programming with integer indexed enums is very self-documenting at all, it's fine for an interchange format.
@sir Reminds me of https://github.com/real-logic/simple-binary-encoding
@sir is it me or is the publicKey optional's type not specified in the example schema ? I assume it's supposed to be optional<PublicKey> ?
@Ark error of translation to HTML, it's being interpreted as a tag. I'll fix it, thanks
@sir ah, ok. No problem.
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!