Re: how to submit a feature request for glib? oversight?



Peter Jay Salzman <p dirac org> writes:
(snip)
is there a reason i'm not thinking of why they don't do this? 


Peter,

Even if the API were being created from scratch, I think that a very
good argument could be made that the length should not be returned,
because doing so would encourage developers to keep track of the string
length separately.  

There is already a public field specifying the length.  That should be
accessed when the length is required.  Doing so prevents a whole class
of possible errors in which the length might be stored, and then later
used incorrectly after another manipulation of the GString.  

Furthermore, given that a major feature of using GStrings is that the
developer (and application) rarely needs to care low long the string is
when doing operations on it, returning the length all of the time would
clutter the code considerably.

I think that a case could be made that those should return a GString*
rather than void, or that the g_string_append() and others should return
a void, as there does not seem to be any clear reason why those
behaviours should differ.

I wonder, were g_string_sprintf and _sprintfa later additions to the
GString API?  I could see how (one) efficient implementation might
require that the GString* be moved whenever the gchar *str was moved. 
All of the other GString calls would support this.

Eric




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