On Tue, Oct 18, 2016 at 5:06 PM, Junio C Hamano <gits...@pobox.com> wrote:
> On Tue, Oct 18, 2016 at 4:52 PM, Stefan Beller <sbel...@google.com> wrote:
>> >
>> > By the way, I do see a merit on the "check" side (tl;dr: but I do
>> > not think "result" needs it, hence I do not see the need for the
>> > "ugly" variants).
>> So we'd rather go with const char **result instead of our own new struct 
>> there.
>> Ok, got it.
> I do not think you got it. I am talking about wrapping struct around
> an array of element,
> not each element in the array. IOW
>> > If we were still to do the wrapping for result, I would say that
>> > basing it around the FLEX_ARRAY idiom, i.e.
>> >
>> >>         struct git_attr_result {
>> >>                 int num_slots;
>> >>                 const char *value[FLEX_ARRAY];
>> >>         };
> the structure around the array of elements (value) that allows us to have
> something other than value[] in it. That is what I said "I do not see
> the need for".
> It is perfectly fine future-proofing to have
> struct git_attr_result_value {
>   const char *value;
> };
> and have the users of API declare
> struct git_attr_result value[5];
> or whatever. That way we could fatten the structure later if we wanted
> to without having to update the users of API, and there is no downside.
> Having wrapping strut around the array does have a huge downside,
> and that is what I said I see no need for.

I am not sure if I see the upside on wrapping a single value except for
its future proofness, i.e. what if we want to transport information that
is valid for all values, e.g. an error code or that the result check was done
lazily (for non lazy you would need to do X) or ...

IOW I would expect there to be more use cases for information regarding
all the values and not each value enhanced by a thing.

We could just repeat the thing in each of the 5 values in
> struct git_attr_result value[5];

I'll go with that.

Reply via email to