Compile-time reflection

Bruno Medeiros brunodomedeiros+spam at com.gmail
Wed Jul 11 05:15:39 PDT 2007


Kirk McDonald wrote:
>>
>> I'm not sure about some of the detail, but in a general wey, yes it 
>> would be welcome to have such changes that would allows us to better 
>> work with functions. Some of the issues here are not just about 
>> compile time reflection, for instance, that you have to create a 
>> temporary type, or do a cast, to get a function pointer of a 
>> particular overload, seems quite hackish to me.
>>
> 
> This would not change that. In fact, I honestly see nothing wrong with 
> that. Casting seems like simplest way of specifying the overload, 
> without introducing new syntax. (Although I'm aware some folks want to 
> introduce new syntax for this express purpose.)
> 

Casting is a kludge, and should not be used for something that is 
perfectly normal, valid (and possibly common). Fortunately we can hide 
it with some cleaner templates:
   auto fn2 = overload!(fn, int, char) // select fn(int, char) overload
I don't think new syntax should be added. But that doesn't mean that 
some things could not be improved with the current design. For instance, 
taking the address of an overloaded function without a cast (or another 
overload selection mechanism) should result in a error, instead of 
simply returning the address of the lexically first overload.

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list