Re: g_(s)list_data()
- From: Joel Becker <jlbec evilplan org>
- To: Derek Simkowiak <dereks realloc net>
- Cc: gtk-devel-list gnome org
- Subject: Re: g_(s)list_data()
- Date: Fri, 25 May 2001 01:28:58 +0100
On Thu, May 24, 2001 at 05:08:18PM -0700, Derek Simkowiak wrote:
> I disagree that this is nice to read. I'd prefer to just see the
> typecast -- at least then a new user will know what's going on (instead of
> needing to lookup yet another macro, especially one that doesn't exist
> in any of the current code).
The macro can be learned. I'm of the 'private accessor' school
of thought, so I like the non-casting version better. This is certainly
a matter of taste. Do you use
foo = g_new(Foo *, 1);
or
foo = (Foo *)g_malloc(1);
? I personally prefer the former.
> It would need to follow the "object-like" Glib naming convention
> of
>
> g_thing_action(GThing *thing, ... )
That's fine. I was following g_new(), but you are right with
this one.
> Although g_list_next() exists, it has been agreed that there is
> way too much code that directly accesses list->next to deprecate that kind
> of peeking. In short, even if list->next was meant to be private, through
> real-world practice it has become public. And since list->data is already
> public, there is no need for g_list_data().
I know folks use list->next and list->data. I am not, in any
way, claiming we can fix it in existing code. But we can provide pretty
accessors for new code that some folks might like.
> As a frequent Glib user, if g_list_data() gets added, I will still
> use list->data in all my code. Sorry :)
Go right ahead. This is certainly a structure we can't change
due to compatibility with existing code. But I think direct structure
access is semi-ugly outside of its library. This is my preference (and
probably some chunk of folks as well, but certainly not everyone).
Joel
--
"Every new beginning comes from some other beginning's end."
http://www.jlbec.org/
jlbec evilplan org
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]