Generic code: @autoconst, @autopure, @autonothrow

bearophile bearophileHUGS at lycos.com
Sun Aug 29 13:55:19 PDT 2010


Simen kjaeraas:
> Please do elucidate.

I am not able to design user-defined attributes in a short time all alone :-)
I'd like to be able to define scoped attributes in normal D code, so you can extend a bit the D type system in user-code, using static introspection (using __traits and other things).
("scoped" means that you are able to use them only in the scope where you have defined them, and you are able to import them).


> Does the second part of my post perhaps help define
> something akin to what you envision?

It's a starting point, but in my opinion quite more design work is needed.

First of all I'd like to define one attribute, for example using alias:
alias @attribute(SomeCondition!A)[A...] @autopure;

You may even use a template-like syntax, but it's a bit overkill:
@attribute autopure(A...) {

You are surely able to do better.
Anyway, I think all this is for D3. For D2 I think it's better to fix the features already present or planned before creating new ones. The bug reports I've suggested to Don (among my ones) in my opinion comes before truly new features.

Bye,
bearophile


More information about the Digitalmars-d mailing list