std.range.put vs R.put: Best practices?

Jon Degenhardt via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 20 11:08:27 PDT 2017


Documentation for std.range.put 
(https://dlang.org/phobos/std_range_primitives.html#.put) has the 
intriguing line:

> put should not be used "UFCS-style", e.g. r.put(e). Doing this 
> may call R.put directly, by-passing any transformation feature 
> provided by Range.put. put(r, e) is prefered.

This raises the question of whether std.range.put is always 
preferred over calling an output range's 'put' method, or if 
there are times when calling an output range's 'put' method 
directly is preferred. Also, it seems an easy oversight to 
unintentionally call the wrong one.

Does anyone have recommendations or best practice suggestions for 
which form to use and when?

--Jon


More information about the Digitalmars-d-learn mailing list