A #define (and all other preprocessor directives, e.g. #include , #ifdef, etc) are handled by the C preprocessor (cpp) and not the compiler. #define is a basic search and replace text operation that takes place before the compiler runs.
I think the arduino team is rightly more concerned about how easy an example is for the user to understand than how efficient the code will be.
#define pin 13...digitalWrite(pin,HIGH);
#define pinOn digitalWrite(13,HIGH)...pinOn;
#define ITEM_CNT(x) (sizeof(x)/sizeof(x))
#defines are more efficient because the compiler can hard code the values in the hex file.
static const uint8_t pinLED = 13;
You can also define a variable with the const attribute to serve the same purpose.
#define pinLed 13
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16