Re: batching gets and searching



>To: Colm Smyth <Colm Smyth ireland sun com>
>Cc: gconf-list gnome org
>Subject: Re: batching gets and searching
>From: Havoc Pennington <hp redhat com>

>Colm Smyth <Colm Smyth ireland sun com> writes:
> ...
>
>Let's call the function gconf_text_search_new() to allow a future
>gconf_search_new() that does some more complete type of search.

Fine; the main difference is that it will be possible to
refine the search to look only at certain data-types.

>> >The convention in G* libs is "GConfSearchFlags flags", for better 
or
>> >worse, where GConfSearchFlags is the enum containing the flags.
>> 
>> The individual flags should be an enum, but the flags may be ORed 
together so
>> the API argument should be an int.
>>
>
>I agree in principle, but the convention in G* world is different,
>there's no point breaking it.

Grep-ing glib.h confirms this. The convention is ok when writing
in C, but is broken with C++. As soon as you perform arithmetic
on an enum value, it becomes an int. Sun's CC is tolerant
about this, but it's actually an error:

% cat enum.C
#include <stdio.h>

enum going { ready, set, go } ;

void print_going(going g)
{
        printf("going = %d\n", g);
}

int main (int argc, char *argv[])
{
        going g = ready|set;
        print_going(ready|set);
}
% make enum
CC    -o enum enum.C 
"enum.C", line 12: Warning (Anachronism): Using int to initialize 
going.
"enum.C", line 12: Note: Type "CC -migration" for more on 
anachronisms.
"enum.C", line 13: Warning (Anachronism): Formal argument g of type 
going in call to print_going(going) is being passed int.
2 Warning(s) detected.

Ironically, gcc treats this as an error!

% /usr/local/bin/gcc enum.C -o enum
enum.C: In function `int main(int, char **)':
enum.C:12: conversion from `int' to `enum going'
enum.C:13: conversion from `int' to `enum going'
% ./enum
./enum: Command not found

I don't like to assume that the clients of GConf will
always be written in C.

Colm.

>Havoc
>
>_______________________________________________
>Gconf-list mailing list
>Gconf-list gnome org
>http://mail.gnome.org/mailman/listinfo/gconf-list

--
Colm Smyth - Sun Microsystems, Ireland - Desktop S/W Engineering
Sun Xtn: 19166    Phone: 353-1-819-9166   Fax: 353-1-819-9200





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