Hacker News new | ask | show | jobs
by 0xmohit 3539 days ago

  One day I'll have to work with people who learned from
  this (and others like it), and it will be a long painful road
  to help them unlearn.
Quoting from the link you've mentioned:

  #define add(a, b) a + b
I couldn't agree with you more.

--

To elaborate:

  add(1, 8) * add(5, 1)
wouldn't yield 9 * 6 = 54, but

  1 + 8 * 5 + 1
which is 42. One might say that it's correct, since it's the Answer to the Ultimate Question of Life, the Universe and Everything.
1 comments

Which is why anyone who has experience programming in C would instead write:

  #define add(a, b) ((a) + (b))
One may also do:

  add(x, foo(x))
Which is why anyone who has experience programming in C would use (an inline) function instead.