Re: Variable-sized lines of text in linked list



Randy Howard said:

<snip>

Since we're on the topic of these, can you comment on why your fgetline
and fgetword functions seem have an inconsistent API?

For example:

int fgetline(char **line, size_t *size, size_t maxrecsize, FILE *fp,
unsigned int flags);

int fgetword(char **word, size_t *size, const char *delimiters,
size_t maxrecsize, FILE *fp, unsigned int flags);


It seems to me it would be a lot more consistent if the common
arguments to both functions appeared first and in the same order.

Well, they /are/ in the same order - but one takes an extra parameter. So
the question is where the delimiters parameter should go.

At the beginning? No - that's a really good place for the thing that
actually gets changed (following in the footsteps of *printf, strcpy,
strcat, memcpy, memset, etc).

At the end? No - that's a really good place for frequently-unused optional
information.

So it has to go somewhere in the middle. And once we've determined that,
it's really a matter of taste.

If you can come up with a compelling argument for putting the parameter
elsewhere, I'm all ears.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages