Re: patch for g_nullify_pointer() and friends



On 4 Aug 2001, Owen Taylor wrote:

> 
> Sven Neumann <sven gimp org> writes:
> 
> > Hi,
> > 
> > here's a small patch that adds g_nullify_pointer() to glib and 
> > g_object_[add|remove]_weak_pointer() to gobject. OK to commit?
>  
>  * By agreed upon convention g_nullify_pointer should
>    be g_nullify_pointer_handler(). 

i think this is taking things a bit far, there's no confusing
co-variant of this function like we had it with
gtk_widget_handler_make_insensitive() vs. gtk_widget_set_sensitive().
so i don't quite get the need of adding _handler_ here, in fact
i think it'd just make the docs more confusing/the function harder to
find.

>  * Is it really generally useful beyond add/remove_weak_ref()?

yes, i've been using such a function from my ealy gtk days on,
i think even gubi had gtk_nullify_pointer(). if it has to
get some obscured name, i'll probably endup with
#define g_nullify_pointer  g_some_obscure_name
for my code.

>  * Your macros are missing a cast to GWeakNotify.

they were probably just c'n'p-ed from my email which i didn't
run through a compiler.

>  * The advantages of making g_object_add/remove_weak_ref() macros
>    are:
>  
>     - One less function call. (But this function call, in the
>       event it turned out to be a performance problem, 
>       could be optimized away inside gobject.c as well.)
> 
>     - Slightly decreased code size in the library
> 
>    The distandvantages are:
> 
>     - Can't use inline docs (if you go with macros, you _must_
>       add an entry to docs/reference/gobject-overrides.txt
>       and then fill in the docs in  docs/refererence
> 
>     - Worse error messages from the compiler.
>  
>     - Worse g_return_if_fail() messages.
>     
>     - Slightly increased code size and startup time in
>       the app (the compiler needs to do a load-time lookup of 
>       g_nullify_pointer)
> 
>     It's not a big deal either way - I'd certainly go
>     with the functions myself. (I _did_ go with the functions
>     myself in the earlier patch I submitetd...)

i don't have a strong preference to express, other than that i 
think we should really stay with g_nullify_pointer() for this.

> 
> Regards,
>                                         Owen
> 

---
ciaoTJ





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