S
steve yee
i think c should adapt c++ template standard, as well as namespace. if
so, c can replace c++ in many cases.
so, c can replace c++ in many cases.
steve said:i think c should adapt c++ template standard, as well as namespace. if
so, c can replace c++ in many cases.
Tom said:What do you like about C that isn't in C++?
Tom
jacob said:Simplicity.
No automatic constructors, no OO orientation.
C has a lot of advantages.
steve said:yes. what i mean is that c can adapt template and namespace from c++,
because it's very useful and does not hurt the simplicity of c. this
will not make c become c++, because there's much more than generic and
namespace in c++'s feature.
steve yee said:i think c should adapt c++ template standard, as well as namespace. if
yes. what i mean is that c can adapt template and namespace from c++,
because it's very useful and does not hurt the simplicity of c. this
will not make c become c++, because there's much more than generic and
namespace in c++'s feature.
Christopher said:How do you propose to make use of templates without introducing the
notion of a class?
steve said:i think c should adapt c++ template standard, as well as namespace. if
so, c can replace c++ in many cases.
i think c should adapt c++ template standard, as well as namespace. if
so, c can replace c++ in many cases.
Julienne Walker said:Adding a turing complete sub-language won't hurt the simplicity of C?
steve said:i think c should adapt c++ template standard, as well as namespace. if
so, c can replace c++ in many cases.
But C++'s templates operate on classes, and really kind of needs to use
them, so I don't know how you could do that without making C really
close to C++.
namespaces I agree with. In fact, its one of those obvious
self-contained features from C++ that isn't really OO related and
solves a real problem that exists in C. (Unlike arbitrarily locatable
declarations, which exists in C++ specifically to solve a problem with
constructors.)
Walter said:Although arbitrarily locatable declarations may not solve a semantic
problem in C, as a programmer I like to have them.
It is fairly common to not need variables until relatively far into a
function; it is useful to be able to hold off declaration of the
variables until a convenient logical point. It makes coding simpler
than having to go back to the beginning to add in a variable, and it
leaves the type information close to where the information is required
instead of having to search back for it.
One can simulate them in C by using blocks and declaring the variable
at the beginning of the block, but that pushes the indentation level
further in.
steve yee said:i think c should adapt c++ template standard, as well as namespace. if
so, c can replace c++ in many cases.
How do you propose to make use of templates without introducing the
notion of a class?
Templates may work fine for functions, but you open the functionDave said:By writing type-generic code once and using it type-safely for different
types, which works just as well for functions as it does for classes.
If you make the template parameters part of the function's name, you
don't even have to introduce overloading, though that does require the
template parameters at every use of the template instead of having the
template function be an overloaded function named by the template name.
--------
/*Generic template for scalar types*/
template<typename T>
int less<T>(const T *left, const T *right)
{ return *left < *right; }
Christopher said:How do you propose to make use of templates without introducing the
notion of a class?
goose said:<OT>
I suppose plain 'ol generic functions? In the presence of function
overloading I'd expect something like this
header:
void foo (<X> arg1, <Y> arg2);
implementation:
void foo (int arg1, float arg2) { ... }
void foo (int arg1, int arg2) { ... }
void foo (struct mystruct arg1, int arg2) { ... }
Although it'd be a pain to write a function
definition for all the types of arguments that
the generic function "foo" can be called with.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.