Andrey:

I think such words as "single" and "only" are more appropriate in your case.

single static function();

Right, but we generally try to minimize the number of keywords.

"static static" is a special case of a more general feature, @templated(), that is similar to the "utilizes" keyword discussed here, in Figure 21:

"Minimizing Dependencies within Generic Classes for Faster and Smaller Programs" by Dan Tsafrir, Robert W. Wisniewski, David F. Bacon and Bjarne Stroustrup:

http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.155.1773


The "static static" is the same as an empty @templated():


int foo(T)() if (is(T == char) || is(T == dchar) || is(T == wchar)) {
    @templated() dchar[] table = ['a', 'b', 'c'];
    @templated() immutable val = someHeavyCTFE(10);
    // uses table and val here
    return 0;
}


Adapted from that Figure 21:

struct C(X, Y, Z) {
    void f1() @templated(X, Z) {
        // only allowed to use X or Z, not Y
    }
    void f2() {
        // for backward compatibility, this is
        // equivalent to: void f2() @templated(X,Y,Z)
    }
    class Inner @templated(Y) {
        // only allowed to use Y, not X nor Z
    }
}


@templated() (or @utilizes()) is much more flexible than "static static". And I generally I'd like @templated() to be implemented instead of "static static".


Or, if the developers will finally allow to take advantages of the unicode: static², static³... :-)

Please, no :-)

Bye,
bearophile

Reply via email to