Recommendations on avoiding range pipeline type hell
Jordan Wilson
wilsonjord at gmail.com
Sun May 16 09:17:47 UTC 2021
On Sunday, 16 May 2021 at 07:20:52 UTC, Chris Piker wrote:
> On Saturday, 15 May 2021 at 14:05:34 UTC, Paul Backus wrote:
>
>> If you post your code (or at least a self-contained subset of
>> it) someone can probably help you figure out where you're
>> running into trouble. The error messages by themselves do not
>> provide enough information--all I can say from them is, "you
>> must be doing something wrong."
>
> I just tacked on `.array` in the the unittest and moved on for
> now, but for those who may be interested in the "equivalent but
> not equivalent" dmd error message mentioned above, the code is
> up on github. To trigger the error message:
>
> ```bash
> git clone git at github.com:das-developers/das2D.git
> cd das2D
> rdmd -unittest --main das2/range.d # This works
> ```
> In file `das2/range.d`, comment out lines 550 & 553 and
> uncomment lines 557 & 558 to get alternate definitions of
> `coarse_recs` and `fine_recs` then run rdmd again:
>
> ```bash
> rdmd -unittest --main das2/range.d # No longer works
> ```
>
> In addition to the issue mentioned above, comments on any style
> issues, best practices or design choices are invited. By the
> way the writeln calls in the unittests just temporary.
Essentially, `dr_fine` and `dr_coarse` are different types. For
example:
```bash
echo 'import std; void main() { auto a = [a,"test"]; }' | dmd
-run - # your error
```
Another example:
```d
auto r = [iota(1,10).map!(a => a.to!int),iota(1,10).map!(a =>
a.to!int)]; # compile error
```
Using ```.array``` on both of the elements of r will compile.
Thanks,
Jordan
More information about the Digitalmars-d-learn
mailing list