Re: Default values for properties



On 4 Mar 2001, Martin Baulig wrote:

> This means that my `set_property()' handler can't figure out whether the
> user explicitly set a property or whether it's just the default value of it.
> 
> What do you think about adding a G_PARAM_NODEFAULT flag to request that a
> property won't get its default value if it isn't explicitly set ?

g_object_new() will only set G_PARAM_CONSTRUCT* proeprties for you, but yes,
it will set those with default values if not upplied by the user.
the reason for this is two fold, basically we do what a c++ constructor
would do if you supplied all of its arguments with default values, but,
probably more interesting, i took that behaviour over from 1.2.

a flag as you suggest would only affect CONSTRUCT properties, however
that will cause us ending up with four variants thereof:

G_PARAM_CONSTRUCT		/* supply always for constructor */
G_PARAM_CONSTRUCT_ONLY	        /* supply if and only if we're constructing */
G_PARAM_CONSTRUCT_EXPLICIT	/* supply with constructor when user-provided */   
G_PARAM_CONSTRUCT_ONLY_EXPLICIT /* supply if and only if (constructing &&
                                                          user-provided) */

i'm not sure that thse additional flags aren't more intriguable than
benefitting.
OTOH, since we now have GObjectClass.constructor, i'm not sure
we still have to default-supply all construct properties at construction
time. but before i change that, i'd like to know why you have to distinguish
"user specified construct property with default value" from
"construct property gets default value, but wasn't user-specified".

> 
> -- 
> Martin Baulig

---
ciaoTJ





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