I mean RAM. #define takes no space in RAM, int does. I don't see the benefit to setting aside 16 bits of RAM to hold the number of a pin and declaring it fixed in value. Carrying type information by being locked to a single fixed representation at run-time invites hidden promotion of the underlying value which is wasted run-time effort, #define should prevent that and let the compiler figure out the best representation for each reference to the value.

I'm not concerned at all about the compiler's work space, just my own.

Carrying type information by being locked to a single fixed representation at run-time invites hidden promotion...

From int to what?

Quote

...#define should prevent that and let the compiler figure out the best representation for each reference to the value.

Why do you believe the compiler does not do the same with const int?

A const int is still just an int. While the compiler "might" optimize away the storage space requirement in RAM or ROM, it has absolutely no obligation to do so. The compiler is free to completely ignore the qualifier. Why depend upon something that might not even happen?

By forcing a defined type, you force the (non optimizing) compiler to promote the type here and there when it is used. People do it all the time by assigning an LED pin to an int when the real type is uint8_t. Since #define constants are basically typeless, the compiler is free to plug it in anyway it sees fit depending upon the context of the reference.

The answer to your third question is contained within the first answer. const is just a qualifier, the compiler doesn't have to do anything special just because it's there. Even attempting to change a const is implementation defined so there's not even a guarantee on how that is handled.

So your entire argument is based on a hypothetical C++ compiler that may or may not exist. Got it.

Given where we are, I will focus my attention on the compiler used to generate code for Arduinos.

Actually, my entire argument is based upon the ANSI standard definition. Given this is the forum to discuss other microcontrollers and not just the microcosm of Arduino, I think I'll stick with standard C and not what some particular compiler may or may not do with optimizations.