[Issue 4703] Ambiguously designed array syntax

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 21 12:51:34 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4703



--- Comment #3 from David Simcha <dsimcha at yahoo.com> 2010-08-21 12:51:30 PDT ---
I think, then, that we should just get rid of the static initialization of
static arrays thing.  I've been using D on a daily basis for ~2.5 years and I
didn't know it existed.  I've never actually seen it used in any D code
anywhere.  IIRC it's not mentioned in TDPL, and it certainly creates a horrible
ambiguity.  If this feature is really that important, maybe it could be moved
to a library and handled with CTFE.  Here's a quick and dirty example of such a
function, which could be tested, fleshed out, etc.

auto staticInitializeStaticArray(T...)(T args) {
    static assert(args.length % 2 == 0);
    T[1][T.length / 2] ret;

    foreach(ti, arrIndex; args) {
        if(ti % 2 == 1) {
            continue;
        }

        ret[arrIndex] = args[ti + 1];
    }

    return ret;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list