alias A = B; syntax

Don Clugston dac at nospam.com
Tue Oct 16 02:32:48 PDT 2012


On 16/10/12 05:18, Nick Sabalausky wrote:
> On Tue, 16 Oct 2012 05:00:56 +0200
> "stas" <stasoid at yahoo.com> wrote:
>
>> For me syntax alias int Int; seems unnatural.
>> I'd love to write
>> alias Int = int;
>> alias fptr = void(int)*;
>>
>> This looks much more readable for me and harmonized with
>> int x = 0;
>> template T(alias A = Object) {...}
>>
>> Does anybody share this opinion?
>> Any chance this syntax goes into D someday?
>
> I'm pretty sure it was already decided that this would be added, but
> just hasn't made it in yet. I've been fairly eager for it. I find the
> current syntax too inconsistent and confusing.
>

That's my recollection too. I find that even after using it for years, I 
still have to pause and think for a moment whenever I see an alias:

alias Foo Bar;
// is this declaring Foo as an alias of Bar? Or Bar as an alias of Foo?
And if I see:
alias Foo int;
it doesn't instantly stand out to me as the wrong way round. There's a 
delay of 1-2 seconds.

Somehow this is something that my brain refuses to see as natural, no 
matter how many times it sees it. Whereas:

alias Bar = Foo;

is instantly clear, even though I've almost never seen it.



More information about the Digitalmars-d mailing list