std.compress

Jonathan M Davis jmdavisProg at gmx.com
Tue Jun 4 11:55:40 PDT 2013


On Tuesday, June 04, 2013 11:46:48 Walter Bright wrote:
> On 6/4/2013 11:43 AM, Timothee Cour wrote:
> > writing generic code.
> > same reason as why we prefer:
> > auto y=to!double(x) over auto y=to_double(x);
> 
> The situations aren't comparable. The to!double case is parameterizing with
> a type, the compress one is not. Secondly, compress(lzw) does ABSOLUTELY
> NOTHING but turn around and call lzw. It adds nothing.

Well, I'd expect it to be compress!lzw(), but in any case, what it buys you is 
that you can pass the algorithm around without caring what it is so that while 
code higher up on the stack may have to know that it's lzw, code deeper down 
doesn't have to care what type of algorithm it's using. Now, whether that 
flexibility is all that useful in this particular case, I don't know, but it 
_does_ help with generic code. It's like how a lot of std.algorithm takes its 
predicate as an alias.

- Jonathan M Davis


More information about the Digitalmars-d mailing list