www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Re: DMD 1.031 and 2.015 releases

reply Robert Fraser <fraserofthenight gmail.com> writes:
Walter Bright Wrote:

 Robert Fraser wrote:
 Out of curiosity, why doesn't return type deduction work for all 
 functions (is this panned?). It seems to be possible to do:
 
 auto foo()()
 {
     return 10;
 }
 
 but not:
 
 auto foo()
 {
     return 10;
 }

Good question! Because deducing the return type requires semantic analysis, and for functions that introduces the old forward reference chicken-and-egg problem. This doesn't happen with function templates, because semantic analysis of them doesn't happen until later.

(Apologies for the web interface) Any way to rewrite them as no-parameter templates automatically if possible and issue a sensible compiler message if they can't be (i.e. a virtual function).
Jun 18 2008
parent Walter Bright <newshound1 digitalmars.com> writes:
Robert Fraser wrote:
 Any way to rewrite them as no-parameter templates automatically if possible and
 issue a sensible compiler message if they can't be (i.e. a virtual function).

It's not impossible, but there's too much else to do at the moment.
Jun 19 2008