Compile-time reflection
Kirk McDonald
kirklin.mcdonald at gmail.com
Wed Jul 11 11:29:46 PDT 2007
Bruno Medeiros wrote:
> 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.
>
I agree with making that an error, so long as we get a way to
automatically derive the types of all of the overloads.
--
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org
More information about the Digitalmars-d
mailing list