DIP6: Attributes

Jacob Carlborg doob at me.com
Tue Aug 4 15:25:46 PDT 2009


On 8/4/09 19:20, Andrei Alexandrescu wrote:
> Steven Schveighoffer wrote:
>> On Tue, 04 Aug 2009 12:23:41 -0400, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>>
>>> Steven Schveighoffer wrote:
>>>> On Tue, 04 Aug 2009 09:45:51 -0400, grauzone <none at example.net> wrote:
>>>>
>>>>> Steven Schveighoffer wrote:
>>>>>> don't think it's worth adding them until we can have full
>>>>>> reflection capabilities so we can get at elements of code and
>>>>>> therefore get the annotations associated with it. I see much more
>>>>>> usefulness for annotations as reflection hints than as a
>>>>>> replacement for keywords.
>>>>>
>>>>> But we already have full reflection. It's called __traits. You can
>>>>> build a serialization library or "proper" (user friendly?)
>>>>> reflection on top of it.
>>>> I think you are the 1 millionth person to say it, and yet we still
>>>> do not have a "user friendly" reflection system. Why is that? You'd
>>>> think that if it could be done, somebody would have done it by now.
>>>
>>> The reality is there's quite few of us. D is not in the stage where
>>> if something could be done, somebody somewhere has done it or is
>>> working on it.
>>>
>>
>> That's understandable, nobody can expect a language as young as D to
>> have everything.
>>
>> But in reality, I think the *theory* that everything is there to build
>> a reflection system is only proven when it actually happens. I'm sure
>> when the enterprising person or persons go to develop it, they will
>> find pieces missing from the static reflection system.
>
> Exactly. I'm absolutely sure there are quite a few things needed here
> and there. I can assure you I'll push hard for those.
>
>> So my point is that adding annotations before reflection works and is
>> implemented makes little sense to me, because the usage of them will
>> be crippled by the fact that reflection isn't complete.
>>
>> What I'd like to see is something like this possible:
>>
>> void foo (int timeout, string bar, float f = 4.0);
>>
>> void foo(int timeout);
>>
>> call!(foo)("timeout=5,bar=\"hello\"");
>>
>> Taking into account the default value of f, what the parameters are
>> named, and which overload to call. I could certainly do it with C#.
>
> This is interesting. It means we'd need reflection for parameter names,
> which currently does not exist.
>
>
> Andrei

It kind of exists:

void foo (int bar);

const str = typeof(&func).stringof;

"str" will contain the parameter names. See: 
http://tango.pastebin.com/m129241b0 for an example.



More information about the Digitalmars-d mailing list