Re: Function completion for GVariant maybe types?



> If you want to find out things about the type of a GVariant then of
> course the GVariantType API is the correct and appropriate way to go
> about it.

Thanks for your acknowledgement.

I stumbled on the detail that the functions "g_variant_is_of_type" and
"g_variant_is_container" are provided directly while some predicates can only be
checked by the others.


> The name is a bit misleading because in our APIs _set_*() tends to mean
> that you're modifying an object in some way (which is not what happens here).

Would you prefer a name like "g_variant_create_maybe_from_source" over my
suggestion "g_variant_set_to_nothing"?   ;-)


> It's also worth noting that the new and the old object have absolutely
> nothing in common except for their type

That is a feature I expect here.


> -- which suggests that you should just use the GVariantType interface
> to get what you want: 
> g_variant_new_maybe (g_variant_type_element (g_variant_get_type (gv), NULL);

I would prefer to call a function with a single parameter for both conditions of
the discussed use case.


>> If the passed instance is a maybe type already, its "container" will be removed
>> while the contained type will be kept. (I would like to avoid the nesting of a
>> maybe type into another one.)
> 
> This is complicated.  Your desire to avoid the nesting of maybe types is
> understandable, but would introduce some inconsistency if we added it in
> the API.

I find your opinion interesting. - I would like to reuse something from the
previous maybe data.


>  If you want to do that in your own code then it is very easy:

Why should it be easier to implement the special copy operation in my code?

Do more GLib software developers need the suggested functionality?

Regards,
Markus


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]