byKey and byValue: properties or methods?

bearophile bearophileHUGS at lycos.com
Tue Jan 17 14:49:24 PST 2012


Andrei Alexandrescu:

> I hate I must ask this:

I am sorry to see you do something you hate :-(

Regarding your question, I'd like keys/values to require () because they do lot of work to create the dynamic array, while I like byKey/byValue to be properties because (I think) their creation is O(1). But now we can't change keys/values. So I'd like to keep all five of them as properties.

I'd like a byPair property too:
http://d.puremagic.com/issues/show_bug.cgi?id=5466

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

There is also the question about code like this:
http://d.puremagic.com/issues/show_bug.cgi?id=5075

import std.algorithm;
void main() {
    auto aa = ["red":2, "yellow":3];
    auto r = map(n => n * n)(aa);
}

Bye,
bearophile


More information about the Digitalmars-d mailing list