range methods on associative arrays
monkyyy
crazymonkyyy at gmail.com
Sun Jul 3 03:36:47 UTC 2022
On Saturday, 2 July 2022 at 20:14:10 UTC, WebFreak001 wrote:
> make more special cases like auto decoding
Its a general problem that ranges are bad are mimicking some
types of for loop patterns; not a specific one
```d
foreach(e;list){
if(e.foo==cond){break;}
e.bar;
}
//if foo is local, it may not scope correctly into std.filter`s
lamda
```
```d
auto store;
foreach(ref e;list){
e=foo(e,store);
store=bar(e,store);
e.foobar;
}
```
one could argue that there are 4 useful data structures that come
out of the box, static arrays, slices, strings, and aa's and that
the benefit of templates is that you get (in theory) great
implications when combining non-specialized data structures and
algorithms; and you would be in effect suggesting the std
increases its special cases to 2 out of 4. (If not 3 with slices
and gc)
I suggest that aa's should follow the rough standard syntax that
is the best I can mimic of defining `[]` to return a range for my
data structures instead of the verbose thing I always have to
look up. And that the algorithms the std define are robust enough
to handle the general problems.
Fundamentally the std is written as if caring that ranges should
be reference types; I dislike that take, but you'd be fighting an
uphill battle to suggest it changes on a real level. And your
suggestion would make the same sort of hacks that string has and
the issues that follow.
More information about the Digitalmars-d
mailing list