Message from C, C++ talks

July 2019

— Imo novices are not ready for constexpr. Const should be first, and const is const vars, const refs and const memfuns - a long way to go. They also need to be taught about const-correctness (cause constexpr implies it), which us not the 1st step in c++ learning
const max would be sufficient

Message permanent page

— Not ready for constexpr, but for a marco? i really doubt that

— Macro vars are very simple and dumb. Nothing to explane but one word - define

— A constexpr int maxAge{100}; is also really dumb

— 

I see a lot of senior code with magic number defines in it, and i can tell you... the bugs are exactly there

— Yeah, then they might do

constexpr std::string prefix{ "$HOME/myspace/" };

— I trust. But defines are much simplier as constexpr

— But constexpr are typesafe, and thats one of the most important features about c++

— How long your explanation of that would be?

— My point is, const is enough for a novice

— Mh

— I guess we have different opinions on that :)

— Yeah, then we say, that it is good to have a lot of little simple functions. We do

int calc() {
int r{ 0 };
// some shit
return r;
}

constexpr int important_var{ calc() }; // duh

Message permanent page

— Thing is, we can't explain constexpr as "just slap it somewhere, it's a good stuff"

— I think constexpr is even easier to explain than plain const