> On Aug. 31, 2015, 11:20 a.m., Michael Park wrote:
> > What do you think of the following API?
> > 
> > ```
> > JSON::Value value = ...;
> > auto message = protobuf::parse<T>(value);  // message has type Try<T>.
> > auto repeated = 
> > protobuf::parse<google::protobuf::RepeatedPtrField<T>>(value);  // repeated 
> > has type google::protobuf::RepeatedPtrField<T>.
> > ```
> > 
> > This makes it so that `parse<T>` always returns `Try<T>`, which I think 
> > enables the use of `auto` for the result under our style guide.
> > I think this is a simpler pattern to remember than `parse<T>` -> `Try<T>` 
> > and `parseRepeated<T>` -> `Try<google::protobuf::RepeatedPtrField<T>>`.
> > 
> > It would take `JSON::Value` rather than `JSON::Array` but check that it is 
> > indeed an instance of `JSON::Array`,
> > the same way the existing version takes `JSON::Value` and checks that it's 
> > an instance of `JSON::Object`.
> > 
> > It also makes the API symmetric with `read()`. We simply do `read<T>` or 
> > `read<google::protobuf::RepeatedPtrField<T>>` and it does the right thing.
> 
> Michael Park wrote:
>     __NOTE:__ `parseRepeated` is actually @joseph's suggestion in the 
> subsequent patch.
>     
>     In this patch, `parse<T>(value)` returns `Try<T>` and `parse<T>(array)` 
> returns `Try<google::protobuf::RepeatedPtrField<T>>`,
>     which I think is just as hard if not harder to intuitively deduce.
>     
>     What do you think?

I think that would be good.  It seems more verbose, but also a lot more 
explicit.

(But I can imagine that it might not fit in 80 characters in some places...)


- Joseph


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/37826/#review97110
-----------------------------------------------------------


On Aug. 26, 2015, 8:38 p.m., Alexander Rukletsov wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/37826/
> -----------------------------------------------------------
> 
> (Updated Aug. 26, 2015, 8:38 p.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Bugs: MESOS-3312
>     https://issues.apache.org/jira/browse/MESOS-3312
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> See summary.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp 
> 57d5fdf45273c620655b44b5f5572290cffa4bf6 
> 
> Diff: https://reviews.apache.org/r/37826/diff/
> 
> 
> Testing
> -------
> 
> make check (Mac OS 10.10.4)
> 
> 
> Thanks,
> 
> Alexander Rukletsov
> 
>

Reply via email to