Negation of attributes (DIP 79)

Kenji Hara via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 4 07:31:53 PDT 2015


2015-06-04 22:41 GMT+09:00 Meta via Digitalmars-d <
digitalmars-d at puremagic.com>:

> It's still trivial to do this without allowing arbitrary expressions,
> since the expressions have to be CTFE-able.
>
> enum constIsEnabled = isConst!(_wrapped.front);
> auto front() const(constIsEnabled) { return _wrapped.front; }
>

In old days I thought a little more generic idea "compilable attribute".

For example:

    // label style.
    // `str` is a CTFEable expression that returns
    // "public", "final", or other built-in attribute name.
    mixin(str): void f1() {}

    // block style
    mixin(str) { void f2() {} }

    // prefix style
    mixin(str) void f3() {}

    // postfix style
    void f4() mixin(str) {}

Similar thing for UDAs

    // tuple contains CT entities that could be UDA.
    @mixin(tuple):

(Note that there's no consideration for feasibility).

But I couldn't find the use case of them.

Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150604/18a3a187/attachment.html>


More information about the Digitalmars-d mailing list