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-18 12:54

>>22
Extrapolating from your post, Lisp and Scheme are ever worse than C, as they are further from modern CPUs than C.

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.

Name: Anonymous 2017-01-18 14:11

>>22,24
Isn't this why C compiler authors add builtin functions and intrinsics to their compilers? How is that any different than someone adding supplementary builtin functions to their Scheme interpreter?

Name: Anonymous 2017-01-18 14:20

>>25
C is meant to talk to the hardware, take the ugliest shortcut there is and abuse the preprocessor to patch up anything missing. Intrinsics are here forever(and will be emulated in some future standard), deal with it.
We are not "reinventing the CPU" here, just encapsulating hardware function into a portable interface.
Just because today only X cpus support SIMD, doesn't mean you should abandon SIMD intrinsics because of non-portable nature: someday they would be ported to ARM or translated by compiler to ARM intrinsics. Because of their utility they are going to appear in many programs, creating a huge network effect of using intrinsics and providing incentive to support them on all platforms(essentially software dictating hardware).

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