Re: C needs a BOOST
- From: jacob navia <jacob@xxxxxxxxxx>
- Date: Sun, 07 Oct 2007 01:07:42 +0200
Stan Milam wrote:
user923005 wrote:It would be really nice if C could adopt a really nice algorithms
library like C++'s STL + BOOST.
The recent "reverse the words in this sentence" problem posted made me
think about it.
It's like 5 lines to do it in C++ because of all the nifty algorithms
that come with the language (I think BOOST is going to get bolted on
to the C++ language like STL did).
It's a lot more work in C than C++. Why doesn't C have stacks,
dequeues, and other common, simple tool sets already in its standard
library?
Opinions? Is keeping the language tiny worth the cost of C
programmers having to constantly reinvent the wheel?
Okay, it's more than 5 lines, but a good library (the "toolbox" in my case) can do all the heavy lifting which all the STL and BOOST is.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "toolbox.h"
int main( void )
{
int x_sub;
char wrkbuf[BUFSIZ];
LIST_T list = { NULL, 10 };
char sentence[] = "This program will reverse these words";
while (gettoken( wrkbuf, sentence, " " ) )
add_list_item( &list, dupstr( wrkbuf ) );
for ( x_sub = list.item_count - 1; x_sub > -1; x_sub-- )
printf("%s ", get_item( &list, ( char *), x_sub ) );
puts("");
return EXIT_SUCCESS;
}
Regards,
Stan Milam.
Great Stan.
Problem is, another system, doesn't use 'gettoken", and 'add_list_item' but
GetToken(sentence,wrkbuf," "); // Inversed arguments
addTolist(dupstr(wrkbuf),&list); // Inversed arguments
and slightly slighty different semantics.
Those do exactly THE SAME work as yours, but both systems are
INCOMPATIBLE!
You see the problem?
The discussion is NOT about the difficulty of writing those
functions, but keeping a common INTERFACE so that all similar
libraries are COMPATIBLE!
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
.
- Follow-Ups:
- Re: C needs a BOOST
- From: Richard Heathfield
- Re: C needs a BOOST
- Prev by Date: Re: Better object orientation?
- Next by Date: Re: Better object orientation?
- Previous by thread: Better object orientation?
- Next by thread: Re: C needs a BOOST
- Index(es):
Relevant Pages
|