DMD 0.177 release

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Thu Dec 21 02:05:29 PST 2006


Benji Smith wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> Let me illustrate further why ident is important and what solution we 
>> should have for it. Consider C's response to ident:
>>
>> #define IDENT(e) (e)
>>
>  > ...
>  >
>> ...leading to the following implementation of ident:
>>
>> auto ident(auto x) {
>>   return x;
>> }
> 
> I don't get it.
> 
> Why is it necessary (or even desirable) for functions to return lvalues?

Methods might want to return lvalues, but indeed the need is not 
overwhelming. (They could return pointers after all.) But the point is 
different. You want to have a grip on all types, and ident shows that 
you can't. For example, in current D you can't (barring a hack that I 
saw in a post around here) have a template that takes a function and 
creates one of the exact signature. That is a vastly useful and 
desirable thing to want; think e.g. of a function that memoizes any 
other function.


Andrei



More information about the Digitalmars-d-announce mailing list