Compile-time reflection

BCS ao at pathlink.com
Tue Jul 3 09:55:21 PDT 2007


Reply to Kirk,

> BCS wrote:
> 
>> Reply to Kirk,
>> 
>>> void foo() {}
>>> void foo(int i) {}
>>> void foo(int i, int j, int k=20) {}
>>> The first thing a compile-time reflection mechanism needs is a way
>>> to,
>>> given a symbol, derive a tuple of the signatures of the function
>>> overloads.
>> [...]
>> 
>>> foo.tupleof => Tuple!(void function(), void function(int), void
>>> function(int, int, int))
>>> 
>> Why have this give a type tuple? I'd have it give alias to the
>> overloads them selves.
>> 
> Aliases operate on symbols. All of those functions have the same
> symbol. An alias to a specific overload is nonsensical.
> 

I would clam that an alias to a specific overload being nonsensical should 
in it's self be nonsensical. Why shouldn't I be able to get an alias to a 
specific function even if it is overloaded?

I would propose that an unqualified function name (or an alias of it) would 
be the set of overloads (or alias to them) and a qualified name would be 
a specific function.

I would be interested in way this would be a bad idea.

void foo(int i){}
void foo(Object i){}

alias foo bar; // bar == {foo(int) and foo(Object)}

int i;
bar(i); // works
bar(null); // works

// proposed syntax for overload resolution
alias foo(Object) baz;

baz(i); // fails int i can't be converted to Object
baz(null); // works





More information about the Digitalmars-d mailing list