Re: Creating more generic data structures



Jorgen Grahn <grahn+nntp@xxxxxxxxxxxxxx> writes:

On Tue, 2010-08-10, Ben Bacarisse wrote:
Andrea Crotti <andrea.crotti.0@xxxxxxxxx> writes:
...
and here the class definition:
http://gist.github.com/517457

This is code by someone who has taken the OO red pill. Many people have,
but even C++ does not do generic containers with classes (at least
that's not the key part of the way it's done).

do you see any sense?

Yes I do, but why are you not using C++? If you want this sort of
facility there has to be a sound reason not to use a language that has
it built in. I notice what looks to me to be a gccism is the code so
C++ might well be a real option. People on the team who don't know C++
can program in C-like C++ with very little learning. Alternatively, C
and C++ modules can be linked together with ease.

As primarily a C++ user, I tend to agree. It hurts my eyes to see
people reinventing wheels like std::queue<T>, in different ways every
time.

On the other hand ... what if you say "ok, from now on a C++ compiler
compiles our code, but stay away from everything except the standard
containers"? There is no way to enforce that, and it would slowly pull
more and more code over into C++ land. If I was a C user exclusively,
I don't think I'd like that.

That's true and the problem is not limited to C++. There are situation
where using limited features of C99 would help without hurting
portability (because you happen to know that features X and Y are
implemented on all the targets you care about) but once you drop C90
standard compiler flags, you won't be warned when other, less portable,
parts of C99 sneak in.

It would be good to have flags to turn features on an off (or to warn
about those that are off) individually, but I suspect the demand is low
compared to the effort of providing this facility.

--
Ben.
.



Relevant Pages

  • Re: Why not add namespace feature into standard C?
    ... features, I can't understand why not add this feature into standard C. ... Because the standards people were more concerned with adding arbitrary ... All the compiler vendors have balked. ...
    (comp.lang.c)
  • Re: C++ danger to break due to its weight, fragmentation danger - C++0x
    ... Also not all of the new features will be ... libraries for the standard on the way which are optional. ... extensions to the C++ compiler. ...
    (comp.lang.cpp)
  • Re: I really do like OS X but . . .
    ... >>>Most backwards compatibility problems come from third party developers ... >>>being slow to adopt new technologies, ... >>>either had to implement those features on their own years ago, ... If you need a compiler, ...
    (comp.sys.mac.advocacy)
  • Re: Linux Kernel Device Driver With C and C++
    ... features that were dropped in C99, such as implicit int, or C99 features ... of any well meaning C++ compiler. ... template functions, member access restrictions, ... better of a job inlining calls through function pointers than a C++ ...
    (comp.lang.c)
  • Re: Linux Kernel Device Driver With C and C++
    ... kernel internal headers with C++. ... I'd expect that if I used a C++ compiler essential as if it ... features that were dropped in C99, such as implicit int, or C99 features ... virtual members, and virtual inheritance. ...
    (comp.lang.c)