This is new to me as well. For Java it seems like it discerns the field by
adding "_{field#}" to the end of accessor name. for example getS1(),
getS2(). In C++, which I'm less familiar with, inserts the scope "O"
between two fields, but keeps the same name i.e. "s".
On Sunday, November 5, 2023 at 1:25:00 AM UTC-5 Carl Gay wrote:
> On Saturday, November 4, 2023 at 11:49:41 PM UTC-4 Carl Gay wrote:
>
> Hi. I'm implementing <https://github.com/cgay/protocol-buffers> protocol
> buffers for a case-insensitive language (Dylan) and I'm wondering if
> there's prior art that would give me an idea how to handle the following
> case:
>
> message M {
> string S = 1;
> oneof O {
> string s = 2;
> }
> }
>
> Since fields M.S and M.s are siblings, the names to access those fields
> will collide. I can generate the name "s*" for lowercase "s". Since "*" is
> invalid in proto field names that's future proof.
>
> So I think I have a way forward but I'm curious if anyone knows of other
> languages that have already addressed this, and what they did.
>
> The Common Lisp implementation ignores the problem and relies on it not
> happening. The docs for the PHP implementation don't mention this
> particular problem. (They do mention reserved names such as Empty being
> renamed to PBEmpty, but that's not a problem for Dylan.)
>
> Thoughts? Prayers?
>
> Thanks.
> -Carl
>
>
> A couple more thoughts:
>
> Auto-assigning a different name for the field, such as "s*", would have to
> be resilient to movement of the fields textually within the file. If the
> oneof were moved textually above field S the name "s*" could suddenly name
> a different field.
>
> Another possibility: a custom field option: dylan_name = "s*". This
> assumes access to modify the .proto file, or the need to maintain a copy of
> it.
>
> Maintain a custom name mapping file to pass to the proto parser / code
> generator.
>
> (This is largely an academic exercise. This scenario seems unlikely to
> happen in practice, especially considering the number of Dylan users on the
> planet.)
>
>
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/protobuf/f004118e-d5c0-435a-8e5b-27e7df4dba78n%40googlegroups.com.