alias for regular expressions
Thunderbird via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Sep 15 04:56:49 PDT 2015
On Monday, 14 September 2015 at 07:11:38 UTC, Meta wrote:
> On Sunday, 13 September 2015 at 19:52:20 UTC, Thunderbird wrote:
>> Thanks for your quick reply :)
>
> To expand on that, alias in D is nothing like the C macro
> preprocessor. D specifically disallows tricks like `#define
> true false`. In D, aliases are just another name for a symbol.
> Ex:
>
> struct Test
> {
> int n;
> float f;
> }
>
> alias IntFloat = Test; //IntFloat is just another name for Test
>
> Test t = Test(0, 1.0);
> IntFloat inf = IntFloat(0, 1.0);
>
> //Test and IntFloat are NOT separate types.
> //Use std.typecons.Typedef for that
> assert(t == inf);
> assert(is(typeof(t) == typeof(inf));
Thanks for elaborating!
More information about the Digitalmars-d-learn
mailing list