Add := digraph to D

Chris NS ibisbasenji at gmail.com
Fri Jun 22 13:24:30 PDT 2012


Back in the ancient history of D (y'know, several years ago) 
there actually was an 'auto' storage class as described here, and 
it was the default as with C.  It is retained in the current 
usage so that type inference for undecorated locals would still 
be available, but indeed no longer serves any other purpose.

Lars is still right in the sense that 'const a = b' really isn't 
shorthand for 'const auto a = b'.  However, it's largely moot 
since the original meaning of auto is gone.  Indeed "storage 
class" in general seems to have gotten out of hand, as a term.  
It would be easy enough to clean up by moving the inappropriate 
members out of that list and into a new yet-to-be-named category. 
Of course I suppose the compiler's internals would be free to 
continue seeing them all as one happy family as it now does.

----------

More on topic, the moment I saw the mention of := it immediately 
read as "Pascal like assignment" to me.  I have no problem with 
languages that actually treat this as two operators (: type = 
init) with the digraph as the type inference shorthand, but 
outside those sort of grammars it just feels "out of place."  The 
only place this pattern appears in D is in template parameters, 
and even that has always looked a little funky to me (although 
not so bad as to be abhorrent).

template Foo ( T : ulong = size_t ) { ... }
// accepts any unsigned integral type, and defaults to the size_t 
alias



More information about the Digitalmars-d mailing list