Jump to page: 1 2 3
Thread overview
alias A = B; syntax
Oct 16, 2012
stas
Oct 16, 2012
bearophile
Oct 16, 2012
Nick Sabalausky
Oct 16, 2012
Andrej Mitrovic
Oct 16, 2012
Timon Gehr
Oct 16, 2012
Marco Leise
Oct 16, 2012
Jonathan M Davis
Oct 16, 2012
Rob T
Oct 16, 2012
Jonathan M Davis
Oct 16, 2012
Rob T
Oct 16, 2012
Era Scarecrow
Oct 16, 2012
Nick Sabalausky
Oct 16, 2012
Adam D. Ruppe
Oct 16, 2012
Jonathan M Davis
Oct 16, 2012
Andrej Mitrovic
Oct 16, 2012
Don Clugston
Oct 16, 2012
stas
Oct 16, 2012
martin
Oct 16, 2012
kenji hara
Oct 16, 2012
so
Oct 16, 2012
Nick Sabalausky
Oct 16, 2012
stas
Oct 16, 2012
Andrej Mitrovic
Oct 16, 2012
Tommi
Oct 16, 2012
stas
October 16, 2012
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?
October 16, 2012
stas:

> Does anybody share this opinion?
> Any chance this syntax goes into D someday?

You are not the first one to suggest similar ideas :-)

I think the general answer is: "Not big enough improvement to justify a language change". But I agree your syntax is better. Maybe it's too much late to change it now.

Bye,
bearophile
October 16, 2012
On Tue, 16 Oct 2012 05:00:56 +0200
"stas" <stasoid@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.

October 16, 2012
On 10/16/12, Nick Sabalausky <SeeWebsiteToContactMe@semitwist.com> wrote:
> 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.

Yep.

Paging Dr. Kenji!
October 16, 2012
Am Mon, 15 Oct 2012 23:18:33 -0400
schrieb Nick Sabalausky <SeeWebsiteToContactMe@semitwist.com>:

> On Tue, 16 Oct 2012 05:00:56 +0200
> "stas" <stasoid@yahoo.com> wrote:
> 
> > 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.
> 

Just recently I wondered how the current syntax could possibly have come into existence. >)

-- 
Marco

October 16, 2012
On Monday, October 15, 2012 23:18:33 Nick Sabalausky wrote:
> I'm pretty sure it was already decided that this would be added, but just hasn't made it in yet.

We'd have to dig through the newsgroup archives to be sure on that one. I'm pretty sure that it _wasn't_ decided that we'd add it, but I don't know for sure. But I don't think that it was entirely shot down either.

Personally, I'm so used to the current syntax at this point that I don't much care, and we'd have to add the new syntax on top of the current one (it would break too much code otherwise), which would arguably just complicate the language further. But it's certainly true that plenty of folks would prefer a syntax similar to assignment instead of the current syntax.

- Jonathan M Davis
October 16, 2012
On Tuesday, October 16, 2012 06:08:27 Marco Leise wrote:
> Just recently I wondered how the current syntax could possibly have come into existence. >)

It's the same as C's typedef syntax.

- Jonathn M Davis
October 16, 2012
On 10/16/12, Jonathan M Davis <jmdavisProg@gmx.com> wrote:
> We'd have to dig through the newsgroup archives

Nah just ask Andrei he already confirmed this once.
October 16, 2012
On Tuesday, 16 October 2012 at 04:32:29 UTC, Jonathan M Davis wrote:
> On Tuesday, October 16, 2012 06:08:27 Marco Leise wrote:
>> Just recently I wondered how the current syntax could possibly
>> have come into existence. >)
>
> It's the same as C's typedef syntax.
>
> - Jonathn M Davis

Alias is not the same thing as C's typedef, but I understand it originally evolved out that way from C's version of typedef.

I agree that the current syntax does at first seem inconsistent with most other things in the language, and I found myself typing it in reverse with the = when I first tried using it, eg

alias Int = int;

On the other hand, I could argue that variable declarations are also inconsistent in the same way, eg

int i; // the "declare" keyword is implied

instead of

declare i = int;

So

alias int Int;

is indeed rather consistent with how type declarations are currently done. Unfortunately, inconsistencies create needless waste, but fixing something like that may be not worth the gain once it becomes deeply rooted in the language.

It may not be to late to change the syntax for alias definitions, but the type declarations will no doubt remain as they are, and the rest of it that is the reverse of type declarations will also likely remain as they are.

--rt

October 16, 2012
On Tuesday, October 16, 2012 07:17:54 Rob T wrote:
> On Tuesday, 16 October 2012 at 04:32:29 UTC, Jonathan M Davis
> 
> wrote:
> > On Tuesday, October 16, 2012 06:08:27 Marco Leise wrote:
> >> Just recently I wondered how the current syntax could possibly have come into existence. >)
> > 
> > It's the same as C's typedef syntax.
> > 
> > - Jonathn M Davis
> 
> Alias is not the same thing as C's typedef, but I understand it originally evolved out that way from C's version of typedef.

The syntax is identical except for it being "alias" rather than "typedef" and their usage is near identical. C/C++ will allow you to typedef struct declarations instead of just their name

typedef struct {...} name;

which D won't let you do, and D will let you alias any symbol, whereas C/C++'s typedef only works on types. But since neither actually declares a new type, I'm unaware of any real difference between the two other than those I already mentioned. They're pretty much the same thing, so I don't know why you're saying that they're different.

Regardless, my point was that the syntax was the same and so that's where alias' syntax comes from.

- Jonathan M Davis
« First   ‹ Prev
1 2 3