About ProgressReport and msn-pecan

Felipe Contreras felipe.contreras at gmail.com
Sun Jun 15 07:24:15 EDT 2008

Hi Tim,

On Sun, Jun 15, 2008 at 1:58 AM, Tim Ringenbach
<tim.ringenbach at gmail.com> wrote:
> On Fri, Jun 13, 2008 at 8:18 PM, Felipe Contreras
> <felipe.contreras at gmail.com> wrote:
>> account.h:
>> typedef struct PurpleAccount PurpleAccount;
>> account_private.h:
>> struct PurpleAccount
>> {
>>        char *username;
>>        char *alias;
>>        char *password;
>>        char *user_info;
>>        ...
>>        PurplePresence *presence;
>>        ...
>> }
>> That means that if you include account.h you can't do
>> account->username, because "account" is an incomplete type, just like
>> a void *. Note also that PurplePresence doesn't need to be defined in
>> account.h, hence you remove a header dependency for all the files that
>> include account.h, and you remove all the headers that presence.h
>> include, and so on.
> Couldn't you do the same thing by just not including the extra files,
> and adding struct _PurpleBlah; for each missing type, and changing the
> prototypes to use the struct _PurpleBlah instead of PurpleBlah? (IIRC,
> if you try to do the typedef more than once you get an error, which is
> why I said use the struct version of the name)

I don't understand what you are saying.

> What's the end goal here? Just to speed up compiling and make the
> graph shorter, if technically misleading? (By misleading I mean the
> account module really does use the presence module even though it
> wouldn't show on the graph anymore because the header isn't including
> it)

No. The public and the private fields are two completely different things.

Try to use "hash->size" with GHashTable; you can't. Why? Because you
shouldn't need to know what is being used internally, actually ->size
is not what you would want, you need "hash->nnodes", but you don't
need to care, you just use g_hash_table_size.

Similarly, you don't need to know about GHashNode; it's something
*internal*. if they choose to define that in "ghashnode.h" or
"ghash_private.h" shouldn't matter, because you shouldn't use that
directly. You might find surprising that GHashNode is not available in
any header file, ever. That's a clean modularization.

Why burden the user, the compiler, and the documentation generation
tools with things that should be transparent?

What is _misleading_ is that you need to know all the internal details
of Presence; you don't, you just need the public API. Actually, I just
checked and Presence is properly hiding the internal details, but not
Account, nor Proxy which is used by Account.

>> Great! I propose an API version field, then.
> Maybe I'm dumb, or just haven't been following along. But what does an
> API version field do us in a struct?

struct foo
int version;
gchar *name; /* version 0 */

Oh crap, we need a nickname!

struct foo
int version;
gchar *name; /* version 0 */
gchar *nickname; /* version 1 */

if (foo->version >= 1)
/* do nickname stuff */

Actually, that would be ABI, so, even better :)

Felipe Contreras

More information about the Devel mailing list