Re: Issue 60 in protobuf: Support static values in .proto files

2,864 views
Skip to first unread message

prot...@googlecode.com

unread,
Jan 4, 2011, 2:50:17 AM1/4/11
to prot...@googlegroups.com

Comment #8 on issue 60 by mer...@google.com: Support static values
in .proto files
http://code.google.com/p/protobuf/issues/detail?id=60

I've been wishing for this once in a while.

There's a workaround: Protobuf actually does have a syntax for literal
values: field defaults. So you can define:
message Constants {
optional string constant = 1 [default = "foo"];
}

and access it as Constants::default_instance().constant();


prot...@googlecode.com

unread,
Jan 20, 2012, 4:21:55 AM1/20/12
to prot...@googlegroups.com

Comment #10 on issue 60 by anish...@gmail.com: Support static values

But even though it had getters and setters,
here need only the getters..

prot...@googlecode.com

unread,
Jan 24, 2013, 12:23:39 PM1/24/13
to prot...@googlegroups.com

Comment #11 on issue 60 by chen3f...@gmail.com: Support static values
Support constant in proto is very useful
const int64 DefaultType = 1000;

optional int64 type = 1 [default=DefaultType];

moofish

unread,
Jan 25, 2013, 9:28:39 PM1/25/13
to prot...@googlegroups.com, codesite...@google.com, prot...@googlecode.com
Field options can provide this capability unless you are really looking for the ability to just not type the same value? I would think the default value and field options would work.  It is possible I don't fully understand your use case. 

prot...@googlecode.com

unread,
Oct 6, 2014, 2:39:26 PM10/6/14
to prot...@googlegroups.com
Updates:
Status: WontFix

Comment #12 on issue 60 by xiaof...@google.com: Support static values
in .proto files
https://code.google.com/p/protobuf/issues/detail?id=60

(No comment was entered for this change.)

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

prot...@googlecode.com

unread,
Oct 6, 2014, 2:49:10 PM10/6/14
to prot...@googlegroups.com

Comment #13 on issue 60 by e...@rjump.com: Support static values in .proto
files
https://code.google.com/p/protobuf/issues/detail?id=60

Is there somewhere that explains the reasoning behind not wanting this? Is
there another option/approach/design that resolves this need?

prot...@googlecode.com

unread,
Oct 6, 2014, 4:12:38 PM10/6/14
to prot...@googlegroups.com

Comment #14 on issue 60 by xiaof...@google.com: Support static values
For every new feature we always consider its benefit against the
complication it adds to protobuf API and we usually weigh API complications
much more heavily. For this particular case, it's an major change to
protobuf syntax and will affect every language implementation as well as
all tools that process .proto files. We need a very compelling reason for
such kind of a change but I did not see any. As far as I can see, the
workaround mentioned in #8 works pretty well as an alternative.
Reply all
Reply to author
Forward
0 new messages