[racket] eginner's question on elementary textual replacement...

From: Rüdiger Asche (rac at ruediger-asche.de)
Date: Fri Mar 9 04:39:19 EST 2012

Hi there,

I need a counterpart for the C #define statement, meaning a way to  
textually replace every instance of id at preprocessor time with its  
defined value, as in

#define ONE 1

unsigned int addone(unsigned int theArg)
{
     return (theArg + ONE);
}

I understand that Scheme's macro system is infinitely more powerful  
than C's, so obvious solutions like

(let-syntax [(ONE 1)]
    ((lambda (x) (+ ONE x))
     2))

won't work... so how do I do it? As a related question, what is the  
counterpart of C's enum as in

enum
{
     ZERO=0,
     ONE,
     TWO,
     THREE,
     <etc>
};

?

Thanks especially for your patience with my recurring stupid  
beginner's questions!



Posted on the users mailing list.