Fix transposed ranges

Cym13 cpicard at openmailbox.org
Fri Mar 30 20:43:09 UTC 2018


Hi, I've got the following code that takes a list of files as 
argument and xor them together (demo example sufficient for that 
discussion).

     import std.stdio;
     import std.array;
     import std.range;
     import std.algorithm;

     auto rawContent(string path) {
         return File(path).byChunk(16384).joiner;
     }

     void main(string[] args) {
         args[1..$]
             .map!rawContent
             .array
             .transposed
             .map!(bytes => bytes.fold!((a, b) => a^b))
             .writeln;
     }

This works but compiles with deprecations:

/usr/include/dlang/dmd/std/algorithm/iteration.d(663): 
Deprecation: function `std.range.Transposed!(Result[], 
cast(TransverseOptions)0).Transposed.save` is deprecated - This 
function is incorrect and will be removed November 2018. See the 
docs for more details.
/usr/include/dlang/dmd/std/algorithm/iteration.d(663): 
Deprecation: function `std.range.Transposed!(Result[], 
cast(TransverseOptions)0).Transposed.save` is deprecated - This 
function is incorrect and will be removed November 2018. See the 
docs for more details.

What do you think the best course of action would be to make that 
code resilient to the modification of transposed? I'd very *very* 
much like to keep a straight UFCS line, there's really nothing 
complicated enough with this operation to warrant writting 
boilerplate, yet the straightforward solution isn't 
future-proof...

Any idea?


More information about the Digitalmars-d-learn mailing list