std.compress

Jonathan M Davis jmdavisProg at gmx.com
Tue Jun 4 13:25:21 PDT 2013


On Tuesday, June 04, 2013 13:15:07 Walter Bright wrote:
> On 6/4/2013 11:55 AM, Jonathan M Davis wrote:
> > 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.
> 
> There is zero utility in this:
> 
> auto compress(alias dg)
> {
> return dg();
> }
> 
> Not even for generic code.

If that's all it's doing, then no, it wouldn't be useful to pass it as an 
argument. I was just pointing out that there are plenty of cases where passing 
functions to generic algorithms is an improvement. I haven't looked at what 
you've done yet, so I can't really comment on the details of this particular 
case.

- Jonathan M Davis


More information about the Digitalmars-d mailing list