Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Coding Standard Nazis

Name: Anonymous 2015-02-15 10:59

http://wiki.wesnoth.org/CodingStandards

Do not use #define for constants
#define foo X is not a typesafe approach to define constants. Instead, you can something like the following (in an anonymous namespace) to achieve the same goal in a typesafe fashion.

Do not use C-style casts
The following code,
if(i->second.side() == (size_t)player_number_) {
is considered bad practice in C++ since a C-style cast is overpowered -- if types change around it could end up casting away constness, or performing an implementation-defined data reinterpretation (basically a C-style cast is a compiler-generated combination of static_cast, reinterpret_cast, and const_cast).

Name: Anonymous 2017-01-17 6:34

>>19-20
The main problem with C is abstraction inversion. A programming language is an interface between the user and the hardware.

https://en.wikipedia.org/wiki/Abstraction_inversion
In computer programming, abstraction inversion is an anti-pattern arising when users of a construct need functions implemented within it but not exposed by its interface. The result is that the users re-implement the required functions in terms of the interface, which in its turn uses the internal implementation of the same functions.

In this case, the construct being used is the actual CPU and the interface is the C language.

``Modern'' C compilers like GCC and Clang have so-called ``optimizations'' that turn loops into single instructions. This isn't an optimization. It's just a bad interface.

Name: Anonymous 2017-01-18 13:05

>>23
being close to the CPU wasn't his point, he was talking about having to reinvent CPU instructions inside the language (the fact that Lisp is implemented in C doesn't matter because it's not about efficiency, it's about the usability of language as an interface). I'm not experienced with Lisp enough to know if it has this problem.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List