ch-ch-changes

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Jan 28 09:25:05 PST 2009


Max Samukha wrote:
> On Wed, 28 Jan 2009 06:46:29 -0800, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
> 
>> Max Samukha wrote:
>>> On Wed, 28 Jan 2009 06:01:29 -0800, Andrei Alexandrescu
>>> <SeeWebsiteForEmail at erdani.org> wrote:
>>>
>>>> The thing is, passing by alias allows you a host of options:
>>>>
>>>> * string for short functions
>>>> * function name
>>>> * delegate literal
>>>> * delegate object (there's a bug in the compiler related to that, that 
>>>> Walter knows how to fix)
>>> Does that mean that we'll be able to do this:
>>>
>>> struct S
>>> {
>>>       bool foo(int a, int b)
>>>      {
>>>            return a > b;
>>>      }
>>> }
>>>
>>> sort!(&S().foo)(a);
>>>
>>> ?
>> That I'm not sure about.
>>
>> Andrei
> 
> Compiler probably could create hidden locals for expressions not
> evaluatable at compile time and then alias those into the template? We
> can do that manually, but maybe the compiler could help here?
> 
> Anyway, it's a petty issue.
>   

It isn't. I do plan to push Walter for automatically creating aliases 
for at least certain expressions. This strategy turned out to be 
tremendously useful for string literals (previously you couldn't pass 
string literals as aliases, which doubled the number of deadbeat 
signatures I had to define).

After all, it is silly to have to write:

auto wtf = &fun;
sort!(wtf)(array);

because this is not allowed:

sort!(&fun)(array);

This is drudgery that should be taken care of automatically.


Andrei



More information about the Digitalmars-d mailing list