Re: [gtk-list] Re: ANNOUNCE: C++ wrapper for glib (sorta)



On Wed, 10 Jun 1998, KC5TJA wrote:

> > > public:
> > >     GList* alloc(void);
> > >     void free(GList *list);
> > >     void free_1(GList *list);
> > >     GList* append(GList *list, gpointer data);
> > >     GList* prepend(GList *list, gpointer data);
> 
> FATAL ERROR (Well...fatal to the compiler at least): No need to have the
> initial GList *, since C++ passes this pointer by default (conveniently
> called 'this').
> 
> > > Granted this is pretty sloppy (alloc/free should be contructor/destructor,
> 
> No, please don't: constructors should be for the C++ object itself, but
> not for the GList itself.  I'd prefer the separate allocators.  The reason
> is that GList::alloc() could FAIL (because the glib functions can,
> themselves, return an error), then return an error as a result.

nope, the glib allocation functions assure to bail out if the required
spce can't be allocated.
if for instance g_list_alloc() cannot aquire the space needed, you
will actually see your program aborting due to a g_error() call from
g_malloc().

> A constructor, on the other hand, does not return an error (C++ always
> assumes constructors are successful).  The most you can hope for is to
> throw an exception in that case, and that is pretty sloppy in my opinion. 
> 

---
ciaoTJ



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