typedef support

1,533 views
Skip to first unread message

Arpit Baldeva

unread,
Nov 21, 2016, 7:13:08 PM11/21/16
to Protocol Buffers
Hi,

Are there any plans to introduce typedef support in the Proto files?

Thanks
Arpit

Adam Cozzette

unread,
Nov 23, 2016, 2:24:51 PM11/23/16
to Arpit Baldeva, Protocol Buffers
I don't think we have any specific plans to do this, but we could consider doing at some point if it would be useful. Do you have a particular use case that would benefit from support for type aliasing?

--
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 protobuf+unsubscribe@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Arpit Baldeva

unread,
Nov 23, 2016, 4:04:07 PM11/23/16
to Adam Cozzette, Protocol Buffers
Thanks for the info. Typedef support would be pretty much useful for regular use cases in C/C++ languages. For example, if we have 100 messages that each have a game id, it'd be nice to just typedef say a uint64 to GameId rather than using it explicitly in each place. This avoids errors like someone using int64 accidentally in one of the messages. Another example would be typedef-ing a collection like map or repeated fields which are used in multiple messages. 

--Arpit

Arpit Baldeva

unread,
Jan 17, 2017, 6:29:32 PM1/17/17
to Protocol Buffers, acoz...@google.com
Should I file a GitHub issue for this? I am not sure what the right protocol is. 

Thanks. 

Adam Cozzette

unread,
Jan 18, 2017, 1:59:28 PM1/18/17
to Arpit Baldeva, Protocol Buffers
Arpit, I should just let you know in advance that we tend to be pretty conservative about making a big change like this and so we would probably be reluctant to do it unless it has a major positive impact. I'm skeptical of whether this feature adds enough value, because most of the time I think developers already solve this issue by defining new message types and reusing them as submessages. Feel free to file an issue, though, if you think you can make a good argument for why the feature is worth it.

Arpit Baldeva

unread,
Jan 19, 2017, 12:09:00 AM1/19/17
to Adam Cozzette, Protocol Buffers
Hi Adam,

Thanks for the response. I agree that any change should be scrutinized and evaluated very carefully. 

I am somewhat surprised though. May be it has to do with my primary language background being C++ where typedefs are commonplace. Defining a new message just to embed a single value will work but is cumbersome. Nonetheless, I'll file the issue for further feedback.  

Sincerely,
Arpit  

Timothee Cour

unread,
Apr 5, 2017, 5:49:14 PM4/5/17
to Protocol Buffers, acoz...@google.com
I was also looking for typedef in .proto and landed here.
Seems like an obvious feature to have.


On Wednesday, January 18, 2017 at 9:09:00 PM UTC-8, Arpit Baldeva wrote:
Hi Adam,

Thanks for the response. I agree that any change should be scrutinized and evaluated very carefully. 

I am somewhat surprised though. May be it has to do with my primary language background being C++ where typedefs are commonplace. Defining a new message just to embed a single value will work but is cumbersome. Nonetheless, I'll file the issue for further feedback.  

Sincerely,
Arpit  
On Wed, Jan 18, 2017 at 10:59 AM, Adam Cozzette <acoz...@google.com> wrote:
Arpit, I should just let you know in advance that we tend to be pretty conservative about making a big change like this and so we would probably be reluctant to do it unless it has a major positive impact. I'm skeptical of whether this feature adds enough value, because most of the time I think developers already solve this issue by defining new message types and reusing them as submessages. Feel free to file an issue, though, if you think you can make a good argument for why the feature is worth it.
On Tue, Jan 17, 2017 at 3:29 PM, Arpit Baldeva <abal...@gmail.com> wrote:
Should I file a GitHub issue for this? I am not sure what the right protocol is. 

Thanks. 

On Wednesday, November 23, 2016 at 1:04:07 PM UTC-8, Arpit Baldeva wrote:
Thanks for the info. Typedef support would be pretty much useful for regular use cases in C/C++ languages. For example, if we have 100 messages that each have a game id, it'd be nice to just typedef say a uint64 to GameId rather than using it explicitly in each place. This avoids errors like someone using int64 accidentally in one of the messages. Another example would be typedef-ing a collection like map or repeated fields which are used in multiple messages. 

--Arpit
On Wed, Nov 23, 2016 at 11:24 AM, Adam Cozzette <acoz...@google.com> wrote:
I don't think we have any specific plans to do this, but we could consider doing at some point if it would be useful. Do you have a particular use case that would benefit from support for type aliasing?
On Mon, Nov 21, 2016 at 4:13 PM, Arpit Baldeva <abal...@gmail.com> wrote:
Hi,

Are there any plans to introduce typedef support in the Proto files?

Thanks
Arpit

--
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 protobuf+u...@googlegroups.com.

To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

--
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 protobuf+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages