3 ms·
If your only example to show C++ verbosity fails to compile and is also patently wrong, you are not making a good point. (The constructor is private, the variab
by pmr_ 15y ago
If your only example to show C++ verbosity fails to compile and is also patently wrong, you are not making a good point. (The constructor is private, the variable naming prevents short accessors such as Rectangle::width()). Better:
struct Rectangle {
double x,y, width, length;
};
int main()
{
Rectangle r = {0., 0., 10., 10. };
return 0;
}
This even compiles in C++03. If you really insist on private members,
you will need initializer lists and some changed member names.
The small example error has been worked around with for years by
simply placing the constant on the left side of the comparison. Not
pretty, but effective.
I agree with the general point, though. A functional style can make
C++ much more efficient. It is also the only way to do template
meta-programming and everybody who tries to go into that direction can
benefit from learning Haskell.
- gtani 15y agobookmarked: http://bartoszmilewski.com/2011/07/11/monads-in-c/ http://bartoszmilewski.com/2011/07/11/monads-in-c/ http://bartoszmilewski.com/2010/11/29/understanding-c-concepts-through-haskell-type-classes/ http://bartoszmilewski.com/2010/11/29/understanding-c-concep...
- pmr_ 15y agoI should have mentioned those articles. They are a great example of Haskell influencing a C++ programmer. Although this article might show what the average C++ programmer thinks `using the type system`, `verbosity` and `influencing their style` mean.
- gtani 15y agoAlso found a def of type classes that i like: automatic instantiation + constraint propagation http://blog.garillot.net/post/15147165154/every-single-freshman-cs-question-in-80-lines-of-scala http://blog.garillot.net/post/15147165154/every-single-fresh...
- cpeterso 15y agoIf you replace Rectangle r with struct Rectangle r, your example even compiles in C89. :)