4 ms·
There is the classic example why one should not use the cpp as a replacment for function calls: #define square(x) ((x)*(x)) breaks when called with a++ as arg
by 1ris 13y ago
There is the classic example why one should not use the cpp as a replacment for function calls:
#define square(x) ((x)*(x))
breaks when called with a++ as argument. Does this pre processor address this problem?
- AnimalMuppet 13y agoI think that you're thinking wrong. Lisp "macros" and C/C++ "macros" are different concepts. This is not a cfront replacement.
- 1ris 13y agoIn Lisp one usually does not write something like (begin (set! a (+ a 1)) a), while in c this is pretty common, so this is a extra issue that might be addressed separately.
- roryokane 13y agoI think it does. In your implementation of `square`, you could use `gensym` to first create a new variable to store x in. Then you would write a second statement that evaluates to that variable times itself.