www.digitalmars.com         C & C++   DMDScript  

D - alias, typedef => typedef, typename

reply "Walter" <walter digitalmars.com> writes:
typedef's being strong in D and mere aliases in C has caused some confusion.
Any interest in changing the keywords to:

    alias => typedef        // bonus being it's compatible with C's typedef
    typedef => typename

The downside is existing code must change (not too bad with a global file
search/replace). If this change was to be made, sooner is certainly better.

-Walter
Sep 02 2002
next sibling parent Mark Evans <Mark_member pathlink.com> writes:
I might suggest eliminating the term "typedef" completely because of its C
baggage.  If D semantics are significantly different, then use new names
altogether.  (If you do use tyepdef then it should mean exactly what it does in
C.)

I vote for simply "type" and "typealias".

Mark
Sep 02 2002
prev sibling next sibling parent "Matthew Wilson" <matthew thedjournal.com> writes:
Like the names

"Walter" <walter digitalmars.com> wrote in message
news:al0p32$1jva$2 digitaldaemon.com...
 typedef's being strong in D and mere aliases in C has caused some
confusion.
 Any interest in changing the keywords to:

     alias => typedef        // bonus being it's compatible with C's
typedef
     typedef => typename

 The downside is existing code must change (not too bad with a global file
 search/replace). If this change was to be made, sooner is certainly
better.
 -Walter
Sep 02 2002
prev sibling next sibling parent Patrick Down <pat codemoon.com> writes:
"Walter" <walter digitalmars.com> wrote in
news:al0p32$1jva$2 digitaldaemon.com: 

 typedef's being strong in D and mere aliases in C has caused some
 confusion. Any interest in changing the keywords to:
 
     alias => typedef        // bonus being it's compatible with C's
     typedef typedef => typename
 
I like the current names. As far as I'm concerned typedef finally does what it should have all along. However if you must change I would keep alias and choose a different name for typedef.
Sep 02 2002
prev sibling next sibling parent Pavel Minayev <evilone omen.ru> writes:
Walter wrote:

 typedef's being strong in D and mere aliases in C has caused some confusion.
 Any interest in changing the keywords to:
 
     alias => typedef        // bonus being it's compatible with C's typedef
     typedef => typename
 
 The downside is existing code must change (not too bad with a global file
 search/replace). If this change was to be made, sooner is certainly better.
I like the old version better (probably because "alias" makes it clear that it is an alias), but it is a cosmetic change actually, so no problem with the new syntax either... but wait, it's more to type! =)
Sep 02 2002
prev sibling next sibling parent Mac Reiter <Mac_member pathlink.com> writes:
My vote goes for ditching typedef if it is a problem.  I really like alias,
because it is clear and explicit.  I also like the new typedef behavior, but I
understand that it could confuse C/C++ programmers.  Personally typedef sounds
like exactly the right word for what it does, but it will cause problems for
people having to switch languages...  'type' would work for me.  'typename'
sounds a little too much like 'make up a new name for this type', which is more
like aliasing...  'maketype' might work, if it didn't look so odd.

I don't have a strong preference for particular words to take over 'typedef's
job, but I have no particular interest in maintaining C compatibility.  Kill
typedef and pick any word that sounds right...  Just keep alias the way it is.

Mac

In article <al0p32$1jva$2 digitaldaemon.com>, Walter says...
typedef's being strong in D and mere aliases in C has caused some confusion.
Any interest in changing the keywords to:

    alias => typedef        // bonus being it's compatible with C's typedef
    typedef => typename

The downside is existing code must change (not too bad with a global file
search/replace). If this change was to be made, sooner is certainly better.

-Walter
Sep 03 2002
prev sibling next sibling parent reply Juarez Rudsatz <juarez nowhere.com> writes:
"Walter" <walter digitalmars.com> wrote in
news:al0p32$1jva$2 digitaldaemon.com: 

     alias => typedef        // bonus being it's compatible with C's
     typedef typedef => typename
1. I think this confusion must be corrected. 2. If all must be changed, why not use two new keywords not present in C ? "alias" and "type" will not confuse the C/C++ programmer. But all declaration must be reevaluated for a conversion to "alias" or "type" and keeping "typedef" could make the programmers not evaluate correctly what need be done. They will ignore the concepts and adopt all as "typedef". C -> D typedef type alias
Sep 03 2002
parent reply Pavel Minayev <evilone omen.ru> writes:
Juarez Rudsatz wrote:

 "alias" and "type" will not confuse the C/C++ programmer.
I also think that "type" would be the best choice. But then, it just looks somewhat weird to type something like: type void* HANDLE; Maybe it's better to adopt Pascal syntax? type HANDLE = void*; alias LPINT = int*;
Sep 03 2002
parent reply Mac Reiter <Mac_member pathlink.com> writes:
Maybe it's better to adopt Pascal syntax?

	type HANDLE = void*;
	alias LPINT = int*;
I like that. Does it cause any parsing problems? Mac
Sep 03 2002
parent reply Pavel Minayev <evilone omen.ru> writes:
Mac Reiter wrote:
Maybe it's better to adopt Pascal syntax?

	type HANDLE = void*;
	alias LPINT = int*;
I like that. Does it cause any parsing problems?
Don't think so. What we have is a keyword (type/alias), followed by an identifier, then equality sign, and then everything until the first semicolon is a type description.
Sep 03 2002
parent reply "Sandor Hojtsy" <hojtsy index.hu> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:al3dqt$229p$1 digitaldaemon.com...
 Mac Reiter wrote:
Maybe it's better to adopt Pascal syntax?

 type HANDLE = void*;
 alias LPINT = int*;
I like that. Does it cause any parsing problems?
Don't think so. What we have is a keyword (type/alias), followed by an identifier, then equality sign, and then everything until the first semicolon is a type description.
The "=" sign has the meaning "value assignment" for me. But we already have a syntax : see the template parameters. They use the colon ":" for very similar purpose. So if you really need something after the name of the new type, I suggest: type HANDLE : void*; alias LPINT : int*; Sandor
Sep 04 2002
next sibling parent Hanhua Feng <hhfeng mail.com> writes:
Sandor Hojtsy wrote:
 "Pavel Minayev" <evilone omen.ru> wrote in message
 news:al3dqt$229p$1 digitaldaemon.com...
 
Mac Reiter wrote:

Maybe it's better to adopt Pascal syntax?

type HANDLE = void*;
alias LPINT = int*;
I like that. Does it cause any parsing problems?
Don't think so. What we have is a keyword (type/alias), followed by an identifier, then equality sign, and then everything until the first semicolon is a type description.
The "=" sign has the meaning "value assignment" for me. But we already have a syntax : see the template parameters. They use the colon ":" for very similar purpose. So if you really need something after the name of the new type, I suggest: type HANDLE : void*; alias LPINT : int*; Sandor
I think we can use ":=". Or, without any keyword, HANDLE ::= void *; LPINT := int *;
Sep 04 2002
prev sibling parent Joe Battelle <Joe_member pathlink.com> writes:
type HANDLE : void*;
alias LPINT : int*;
Wow, we're really far a field here. My vote is to keep alias and typedef as they are.
Sep 04 2002
prev sibling parent reply "Luigi" <igiul.reverse email.it> writes:
I think that Alias and Typedef are already the best name to represent their
meaning.
I don't believe that C and C++ programmers will have too many problems to
conform... the concept is very simple to be understood.

Bye

--
Luigi
Sep 08 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Luigi" <igiul.reverse email.it> wrote in message
news:alfkre$117h$1 digitaldaemon.com...
 I think that Alias and Typedef are already the best name to represent
their
 meaning.
 I don't believe that C and C++ programmers will have too many problems to
 conform... the concept is very simple to be understood.
Yeah, it looks best to keep it the way it is. I have further plans for 'alias', too, based on some great suggestions here!
Sep 08 2002
parent reply Pavel Minayev <evilone omen.ru> writes:
Walter wrote:

 Yeah, it looks best to keep it the way it is. I have further plans for
 'alias', too, based on some great suggestions here!
Function aliases? C++-like references?
Sep 09 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:alice3$aou$2 digitaldaemon.com...
 Walter wrote:
 Yeah, it looks best to keep it the way it is. I have further plans for
 'alias', too, based on some great suggestions here!
Function aliases? C++-like references?
Being able to alias any symbol, such as: alias foo.bar.abc myname; It would take the place of the C practice of: #define myname foo.bar.abc
Sep 09 2002
parent reply Pavel Minayev <evilone omen.ru> writes:
Walter wrote:

 Being able to alias any symbol, such as:
 
     alias foo.bar.abc myname;
 
 It would take the place of the C practice of:
 
     #define myname foo.bar.abc
What about local variables? Will I be able to write something like this? void do_smth(Foo obj) { alias obj.list[obj.choice].bar.baz().blah blah; ... } Another question is, will it be calculated just once, or every time alias is used?
Sep 09 2002
parent "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:aliqec$1vev$2 digitaldaemon.com...
 Walter wrote:
 Being able to alias any symbol, such as:
     alias foo.bar.abc myname;
 It would take the place of the C practice of:
     #define myname foo.bar.abc
What about local variables? Will I be able to write something like this? void do_smth(Foo obj) { alias obj.list[obj.choice].bar.baz().blah blah; ... } Another question is, will it be calculated just once, or every time alias is used?
An alias is an alias for another symbol, looked up at compile time, not an alias for an expression. I never thought about using it for an expression.
Sep 09 2002