Do people really still make the `=` vs `==` mistake? GCC -Wall has had "warning: suggest parentheses around assignment used as truth value" since as long as I can remember.
Haskell's effect on my C++ : exploit the type system
11–20 of 57 posts
Re: Haskell's effect on my C++ : exploit the type system
#12Re: Haskell's effect on my C++ : exploit the type system
#13Re: Haskell's effect on my C++ : exploit the type system
#14That first example is terrible. C doesn't guarantee that the arguments to a macro are evaluated only once. At best, you might be doing the computation twice. At worst (if the function has internal state), you could get different answers for the comparison and the assignment. The non Haskell-style is better!
Re: Haskell's effect on my C++ : exploit the type system
#15That first example is terrible. C doesn't guarantee that the arguments to a macro are evaluated only once. At best, you might be doing the computation twice. At worst (if the function has internal state), you could get different answers for the comparison and the assignment. The non Haskell-style is better!
If it's a case where you can retrieve the value essentially free w/o side effects (as opposed to the result of a computation), one idiomatic alternative is:
const int a = foo >= 0 ? foo : 0;Re: Haskell's effect on my C++ : exploit the type system
#16It is a joy to use to.
Re: Haskell's effect on my C++ : exploit the type system
#17Do people really still make the `=` vs `==` mistake? GCC -Wall has had "warning: suggest parentheses around assignment used as truth value" since as long as I can remember.
Re: Haskell's effect on my C++ : exploit the type system
#18In C++11, the language is unaltered from the perspective of a PL researcher, its type systems unchanged, but wildly improved from the perspective of a programmer. Initializer lists, auto, lambdas, and for-each loops were added, all of which make the language more compact in ways which most programmers will appreciate. Futures will do for multi-threading in C++ what RAII did for resource management.
Programmers are not computer scientists. From the perspective a programmer, the big three languages -- C++, Java, Python -- are quite alive and changing in ways which allow us to write better, more interesting programs. Even if they are built on thirty year old type systems.
Re: Haskell's effect on my C++ : exploit the type system
#19> Although the newcomer C# was only introduced ten years > ago, there is little in the language to reflect the > thirty years of research into programming languages since > C++ was introduced. Not a huge fan of C#, but he couldn't have picked a worse example for language stagnation .
The people that develop F# and those who develop a large part of Haskell drink coffee from the same coffee machine.
Re: Haskell's effect on my C++ : exploit the type system
#20Do people really still make the `=` vs `==` mistake? GCC -Wall has had "warning: suggest parentheses around assignment used as truth value" since as long as I can remember.