Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsv-summarize: Slice SummarizerBase._operators when invoking std.algorithm.each #308

Open
jondegenhardt opened this issue Sep 20, 2020 · 0 comments
Labels
code refactor Code refactoring or improvements

Comments

@jondegenhardt
Copy link
Contributor

jondegenhardt commented Sep 20, 2020

Code improvement. SummarizerBase._operators is a doubly linked list (std.container.dlist). It's not an input range, but can converted to one by slicing. This is done in most of the tsv-summarize code, but not in SummarizerBase.processHeaderLine, which directly invokes std.algorithm.each (line 865):

   _operators.each!(x => x.processHeaderLine(lineFields));

This works for std.algorithm.each, but better code would be to slice it (_operators[].each!) to turn it into a proper input range. Identified by Phobos PR #7638. During an intermediate point in the PR buildkite produced the error:

Error: template `std.algorithm.iteration.each` cannot deduce function from argument types
`!((x) => x.processHeaderLine(lineFields))(DList!(Operator))`,
candidates are: /var/lib/buildkite-agent/builds/ci-agent-1274edee-3159-4508-b412-871bec2025b7-3/dlang/phobos/build/distribution/bin/../imports/std/algorithm/iteration.d(805):
  `each(alias fun = "a", Range)(auto ref Range range)`
  with `fun = __lambda2,
        Range = DList!(Operator)`
  must satisfy one of the following constraints:
`       isInputRange!Range
       isArray!Range
       hasMember!(Range, "opApply")`

Note: Given the role of tsv-utils in dlang CI tests, this code should not be modified until the issues raised by the Phobos PR have been resolved. In particular, does each retain backward compatibility (preferably with unit tests), or is it modified in a non-backward compatible way?

@jondegenhardt jondegenhardt added the code refactor Code refactoring or improvements label Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code refactor Code refactoring or improvements
Projects
None yet
Development

No branches or pull requests

1 participant