News for hackers. Stuff that matters.
Re:C will never stop you from making mistakes by mhh__ on Monday August 10, 2020 @11:48AM (#24110549)
D's betterC mode is very good. It's slightly above C in abstraction (i.e you still have generics) but you get all the metaprogramming too (no more macros!)
Re:C will never stop you from making mistakes by virtue3 on Monday August 10, 2020 @12:00PM (#24110675)
Nothing like a good ole:

#define MULTIPLY(a,b) a*b

To ruin your month.

Re:C will never stop you from making mistakes by blovescoffee on Monday August 10, 2020 @12:11PM (#24110791)
Is the problem the use of a macro, which isn't as robust as a template, or is there a problem with the macro? All I can figure is there could be an accidental dereference instead of multiply.
Re:C will never stop you from making mistakes by virtue3 on Monday August 10, 2020 @12:21PM (#24110916)
The problem is macro expansion is not (potentially) what you think it is:

MULTIPLY(2+3,4+5) that expands in

2+34+5 (and not into: (2+3)(4+5)).

To have the latter, you should define:

#define MULTIPLY(a,b) ((a)*(b))

https://stackoverflow.com/questions/14041453/why-are-preproc....

Re:C will never stop you from making mistakes by favorited on Monday August 10, 2020 @03:02PM (#24112795)
But it's so nice and composable! /s

    #define DEREFERENCE(b) MULTIPLY(=, b)

    int thing DEREFERENCE(ptr);
Re:C will never stop you from making mistakes by virtue3 on Monday August 10, 2020 @07:46PM (#24115582)
You sir, are a true monster. I salute you.