Re: g_(s)list_data()

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);


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).



"Every new beginning comes from some other beginning's end."
			jlbec evilplan org

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