September 06, 2007
Bill Baxter wrote:
> But if Kirk doesn't get it, and Don doesn't chime in with "what a great idea" in the next 5 minutes, well ... it's hopeless.
> 
> --bb

I do "get it" (an "alias" is the type of a symbol, you initialize the alias to the symbol, &c &c), I just don't particularly like it very much. This is primarily because it's merely a syntax change. If the old syntax is retained, we have redundant syntaxes, which is annoying and not a good thing. Before removing the current syntax, we have to of course consider the existing body of code which would have to be changed. (I do not think I need to belabor this point. Remember when implicit .ptr conversion was removed? This would be much worse. Removing the existing syntax is Not An Option.) Neither option is a winner.

Last and least, I do not not think it's much of an improvement. It is not like the existing syntax is ambiguous. It's not even unclear. In fact, my most frequent uses of alias render the "rvalue" and "lvalue" of the alias abundantly clear, since the rvalue frequently has keywords and things in it, or at least is more complicated than just an identifier. (Which is usually why I'm aliasing it in the first place.)

-- 
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org
September 06, 2007
Kirk McDonald wrote:
> Bill Baxter wrote:
>> But if Kirk doesn't get it, and Don doesn't chime in with "what a great idea" in the next 5 minutes, well ... it's hopeless.
>>
>> --bb
> 
> I do "get it" (an "alias" is the type of a symbol, you initialize the alias to the symbol, &c &c), 

Sorry for saying that.  I know you understand the concept perfectly.  I was think something more like "get that it would be a worthwhile change" but I just cut out too many words.

--bb
September 06, 2007
Nathan Reed wrote:
> Kirk McDonald wrote:
>> The fact that the syntax looks nothing like assignment underscores the fact that /it is not an assignment/. I would classify the proposal as a foolish consistency, but I wouldn't really care if it were added. (Except that adding redundant syntaxes for the same operation is rarely a good idea.)
>>
> 
> I second the proposal someone already made of allowing
> 
> alias Foo as Bar;
> 
> This doesn't look like an assignment, but makes the declaration more readable and allows one to easily remember which identifier is the alias being created (at least, if one is a native English speaker...) at the slight cost of adding the keyword 'as'.  The 'as' could be optional so as not to break existing code.

I don't think that this will add a lot of clarity.  I don't know about other people, but when I read that syntax above, I still ask the question, "Is Foo being declared to be 'the same as' Bar, or is Bar being declared 'as a new alias of' Foo."

Perhaps it is instantly clear to other folks, I don't know.  But I know that at least one programmer finds the "as" syntax just as unclear as the original.
September 07, 2007
Robert Fraser wrote:
> Janice Caron Wrote:
> 
>> Please could D allow the following syntaxes
>>
>> alias dst = src;
>> typedef dst = src;
>>
>> Instead of (or as well as)
>>
>> alias src dst;
>> typedef src dst;
>>
>> I just prefer the destination on the left. Moreover, it would make for greater consistency throughout D. It would match up with assignment operators, module import renaming, and alias template specializations.
>>
> 
> I think it was done this way to maintain consistency with C's typedefs.

Interestingly, C++ is introducing something like

using newname = oldname;

which, as a simple case, can replace the existing typedef notation

typedef oldname newname;

-- James
1 2 3
Next ›   Last »