Meta:

What about prepending the word static?

immutable data = [1, 5, 3, 1, 5, 1, 5];
void main() @nogc {
    import std.algorithm: count;
    assert(data.count(static[1, 5]) == 3);
}

This is about the same as appending the char 's'.


Or variadic template arguments. Aren't they allocated on the stack like static arrays?

immutable data = [1, 5, 3, 1, 5, 1, 5];
void main() @nogc {
    import std.algorithm: count;
    //Assume count has a variadic template implementation
    assert(data.count(1, 5) == 3);
}

Currently they are allocated on the stack. But "count" doesn't work like that. And I think this feature of D is bug-prone, and in bugzilla I've asked to change it (allocating on the heap on default).

Bye,
bearophile

Reply via email to