-
Notifications
You must be signed in to change notification settings - Fork 5
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
Reserved tag numbers #647
Comments
In Slice: |
Here |
This behavior can already be achieved by just not removing tags:
Now, I see that leaving a bunch of unused fields in your struct isn't desirable, Maybe instead of adding a
It's kind of logically equivalent to
|
It can be partially, the issue with this solution is that the generated code would still contain a field that nobody should be using.
That is fine with me, I was just wondering if the functionality is worth it. And my first impression is that it can be helpful in maintaining Slice definitions that need to evolve over time. |
A downside of this is it might give the impression that these will still be mapped to fields and parameters which they can't be. That might be confusing to users. |
I'm in the same boat. It doesn't seem very important to support, but long-term users might find it helpful. The only issue I can see if that these 'reserved' tags might pile up over time, since anyone who uses this feature would probably be apprehensive to remove them (clearly backwards compatibility is a large concern for them). |
I don't think this issue will be as big a problem for Slice. With protobuf everything is tagged, where as in Slice that is not the case. You have to be a little more careful adding or removing fields. I'm not big not he reserved attribute for operations, it's not obvious how to apply it to parameters or return values separately. One option could be to add something like:
I find that reserved keyword gives the impression that you may want to use it later. But from reading the proto docs, it's really for retiring old tags that should no longer be used. |
I prefer retired/reserved over the "anonymous" tag syntax. The anonymous tag gives the impression you forgot the body of your field. It would also be easy to write hard to read:
Note that Protobuf also allows you to reserve a range. And it has a related feature called "extensions" where you reserve a range of numbers for "extensions". extensions is a proto2 feature... confusing. https://protobuf.com/docs/language-spec#reserved-names-and-numbers |
Good point. If we do decide to support this I also prefer 'retired' over 'reserved' for this use-case. Not clear what a good syntax is for this + return types. |
Currently, a struct/class/operation has a field|parameter list, where each field|parameter has a mostly consistent syntax: (tag(X)] | stream) name: Type I'd like to see a proposal that keeps this nice "list" consistency. |
What about this?
I still think tag should be in the same location as stream: after the |
|
Maybe it's best to shelve this proposal for now. I suspect there just isn't a good syntax for expressing this for return types. And while this idea would be useful, It doesn't really add anything to the language, and I suspect it's use would be niche. |
Related:
Naturally you can also use comments to list retired tag numbers. |
We should consider adding a way to reserve tag numbers, to avoid breaking the client-server contract once you remove a tagged field, by reintroducing a new field that uses the same tag number.
Protobuf provides this functionality with the reserved keyword https://protobuf.dev/programming-guides/proto3/#fieldreserved
This can be implemented as an Slice attribute for constructs that support tags
[reserved(1)] struct Person { name: string tag(1) address: sequence<string>? // <-- Compilation error using a reserved tag number }
Or
interface Greeter { [reserved(1)] greet( tag(1) name: string? // <-- Compilation error using a reserved tag number ) -> string }
Not clear where to put this for the return value.
The text was updated successfully, but these errors were encountered: