> On Aug. 31, 2015, 6:20 p.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.

__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?


- Michael


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


On Aug. 27, 2015, 3:38 a.m., Alexander Rukletsov wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/37826/
> -----------------------------------------------------------
> 
> (Updated Aug. 27, 2015, 3:38 a.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