Const sucks

Regan Heath regan at netmail.co.nz
Tue Sep 11 12:28:44 PDT 2007


Janice Caron wrote:
> On 9/11/07, Nathan Reed <nathaniel.reed at gmail.com> wrote:
>> #define does text substitution.  In C, you could write something like this:
>>
>> #define THREE 3
>> float pi = THREE.14159;
>>
>> With D macros that would not be allowed.
> 
> True. But I want more than that. I want to be able to distinguish between
> 
> const int x = 42;
> const uint x = 42;

No problem:

macro x = 42;   //int
macro x = 42U;  //uint
macro x = 42L;  //long
macro x = 42UL; //ulong

In addition:

macro x = 2_147_483_648; //long

See:
"Decimal Literal"
http://www.digitalmars.com/d/lex.html


Regan



More information about the Digitalmars-d mailing list