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



Peter Jay Salzman wrote:
(snip)
 very different indeed!   

Well, I had certainly missed the distinction the first time.  Sloppy
reading on my part.

I agree that the distinction is real for sprintfa, and the number
returned would be more conventient than the storing/subtracting that you
propose.  

I think that we've reached a matter of faith.  I see at least three API
arguments that all could be readily defended, depending on one's
personal preferences.

0) All GString functions are declared void g_string_.  Access functions
(or macros) are required to query the GString.  Even new GStrings are
returned by handle.  OO-Over-the-top.
1) All GString functions return the number of new characters.  This
favors apparent consitency of API, although some functions would be
returning total length and some the additional length.
2) All GString functions return GString *, allowing uses such as Owen
demonstrated and an efficient, minimal-redirection implementation.
3) All GString functions return whatever is most useful for that
function, i.e. either void or what you and I decide is most likely to be
the bit of information desired by the application after performing an
operation.  Developers are assumed to check the API reference, but if we
guess right the application code is quite clean-looking.  And it may
become the new standard! 
4) All GString functions return whatever their ISO or glibc
nearest-neighbor function returns, for maximum ease of transition.


I write mostly embedded code.  I vote 2) and will defend it to the
death.
:)

Bear in mind that 4) is simply repeating the 3) of previous
implementations.

Actually, I do like 2), but not just for efficiency.  One major goal of
API design when I write library-like code is to make the functions
difficult to misuse.  And I could very easily see myself changing from
an sprintf to an sprintfa somewhere in code, and then acting on what had
been the returned full string length and was now the additional
characters.  But as I said, we're in the realm of stylistic differences.

Eric




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