Proposal: user defined attributes

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Mar 20 09:16:41 PDT 2012


On 3/20/12 11:09 AM, Steven Schveighoffer wrote:
> On Tue, 20 Mar 2012 11:17:02 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>> I'm afraid I disagree. A targeted language feature definitely makes a
>> library approach inferior, by definition. But adding features is
>> cheating, like printing money is for a government: very tempting, with
>> apparently good short-term benefits, but with devastating cumulative
>> effects.
>
> Not exactly. We could all be writing code in assembly if "adding
> features" was always caustic.

This is trivializing my point. Please.

> What is nice about adding this feature is it provides a custom solution
> to hooking the compiler's TypeInfo generation. We are setting up the
> compiler to give us hooks so we *don't* have to extend the compiler
> every time we want new reflection features.

There is something nice about every new feature.

> One of the oft-requested features of D is reflection capability. The
> answer is generally that we have compile-time reflection, which can
> theoretically be used to build runtime reflection. However, the rebuttal
> I always come back with is "yeah, but why should I build at runtime that
> which is obvious at compile time?"

I thought there were discussions that didn't add runtime overhead.

> Note that one library that did attempt runtime reflection capability
> (flectioned) does all this at runtime, and does some really funky shit,
> like opening /proc/self/map on Linux, or requiring you to pass an
> OPTLINK map file. I don't look at these as "innovations" as much as I do
> as workarounds.

Maybe there's a better approach than flectioned. Consider the language 
is frozen solid. How would you solve problems with it?

>> Also, as I mentioned, the availability of the easy escape hatch of
>> adding a language feature thwarts creativity. Nobody will care to
>> think about and come with idioms that use the language to do great
>> things, if they know a language feature could be always added that
>> makes things "nicer".
>
> I have to disagree for this instance, the barrier to creating reflection
> data from compile-time info is very large. If anything, this *expands*
> the ability to create, since you now have a new way to pass information
> from compiler to runtime.

I hope I'll be convinced.


Andrei


More information about the Digitalmars-d mailing list