On 1/19/12 11:19 AM, torhu wrote:
On 17.01.2012 07:48, Andrei Alexandrescu wrote:
I hate I must ask this:

int[string] aa;
foreach (k; aa.byKey) { ... }

or

int[string] aa;
foreach (k; aa.byKey()) { ... }


For it to be a property, I think you should be able to simplify this
example:

---
auto k = aa.byKey;
writeln(k.front);
k.popFront();
writeln(k.front);
---

to this:

---
writeln(k.byKey.front);
k.byKey.popFront();
writeln(k.byKey.front);
---

and get the same result. But my understanding is that you wouldn't, in
which case byKey doesn't sense to me as a property. It creates and
returns a new range object each time you call it, right?

Yah, this is the lvalue vs. rvalue part. I think you are making a good argument.

Andrei

Reply via email to