Re: [gnome-db] Minor API change and MySQL [update/delete]_row
- From: Rodrigo Moya <rodrigo gnome-db org>
- To: Paisa Seeluangsawat <paisa unt edu>
- Cc: GDA <gnome-db-list gnome org>, Laurent Sansonetti <laurent datarescue be>
- Subject: Re: [gnome-db] Minor API change and MySQL [update/delete]_row
- Date: Wed, 29 Oct 2003 18:51:32 +0100
On Wed, 2003-10-29 at 19:39, Paisa Seeluangsawat wrote:
> > > 1) no const object as the first argument
> > >
> > > 2) return const if value shouldn't be edited
> > >
> > > 3) don't force users to cast of const
>
> > I think 3) is the problem, and that's why we are talking about it. Then,
> > if we look at the other libraries we are using ourselves (glib, for
> > instance), we see that that problem does not exist, since const is only
> > used in a very few places.
>
> If you really want (1), then (2) is the one to let go. A guideline
> like (1) implicitly implies that we don't return const object. Do you
> see any glib, gnome, or any good library that return const object, but
> expect to take that object back in non-const?
>
no, that's why I advocate for using const only in a very few places. So:
GdaValue *gda_row_get_value (GdaRow *row);
...gda_value_set_.. (GdaValue *value);
and so on. We'll just return const for functions returning static
strings.
>
> > yes, I know, but a more important objective is to make the API really
> > easy to learn for people who know similar APIs. That is the case for
> > GNOME libraries,
>
> (3) doesn't break familiarity. The user's code stay exactly the same
> whether we take const in a function or not. (2) breaks familiarity.
> The user have to declare a pointer to const object and/or cast off
> const at some point. They don't have to do that in other G/Gtk/Gnome
> libraries
>
no, if we use const only a very few places, like I said above.
>
> > I am more and more in favour of not returning const from the
> > functions, and make the documentation clearly state not to free that
> > returned value.
>
> What you says here is we stay with (3) and break (2). I'm fine with
> this. (3) is more important than (1) and (2), and our current API is
> breaking it. As long as we fix (3), I'm happy.
>
right. That is, we remove all the const's in the API, except for things
like gda_value_get_string and so on.
Thus we solve the problem of having const/non-const issues, and we look
like any other GNOME library.
cheers
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]