DMD 1.038 and 2.022 releases

bearophile bearophileHUGS at lycos.com
Sun Dec 14 17:14:08 PST 2008


This time the compilation of my dlibs (using V.1.038) has gone a little less smoothly.

With V.1.037 this line compiles fine, while statically asserts in V.1.038:
static assert(!is(typeof( xkeys([12:"ab", 5:"ba"]) )));

I have tried to track down the problem, but after going into a rat's nest for 40-50+ minutes I have surrendered and just commented out the line.

That line of code is present inside the unittests of xkeys(), an iterable class whose opApply yields just the keys of the given associative array. Of course that [12:"ab", 5:"ba"] AA can't be accepted because its values aren't dynamic arrays, so it can't use a foreach on it yet.

-----------------------

I have seen the Bug #493 fixed, very nice. Of course the more I have the more I want, so I'd like to be able to do something like this:

import std.stdio: writefln;

struct Spam(T, S) {
    T a;
    S b;
    void show() {
        writefln("typeof(T), typeof(S): ", typeid(T), " ", typeid(S));
    }
}

Spam!(T, S) spam(T, S)(T a, S b) {
    return Spam!(double, int)(a, b);
}

void main() {
    Spam!(double, int)(1.0, 33).show(); // OK
    spam(1.0, 33).show(); // OK
    Spam(1.0, 33).show(); // ERROR
}

Currently I use an auxiliary function (here named spam()) to do this with structs (and classes).
It's just sugar, but may help me avoid about 20-30 little helper functions in my dlibs.

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list