On Sunday, 3 August 2014 at 08:50:47 UTC, Marc Schütz wrote:
On Sunday, 3 August 2014 at 06:19:12 UTC, Freddy wrote:
On Friday, 1 August 2014 at 23:57:37 UTC, Freddy wrote:
I just curious, do Associative Ranges exist. If so where can i
find them. I started thinking about them when i asked this
question:
http://forum.dlang.org/thread/vauuognmhvtjrktaz...@forum.dlang.org
I started a phobos fork for this, what do you think so far
https://github.com/Superstar64/phobos/blob/60d3472b1056b298319976f105aa3b9b3f165e97/std/range.d#L1357-1420

Nice!

A few comments after a cursory glance:

1) "aligns" sounds strange, use "corresponds" instead.

2) It would be preferable that associative ranges mimic built-in associative arrays as closely as possible, i.e. the range members should be called `byKey` and `byValue`, and it should allow iteration over the associative range directly, instead of using the `range` member.

3) For the value and key ranges, there should be a guarantee that they can be zipped through, i.e. that the elements in them are in the same order so keys and values correspond to each other. The built-in associative arrays provide `byKey` and `byValue`, which satisfy this condition.
Also won't the implicit range make it hard to implement function
like map (should you map to whole range or to the value)

Reply via email to