05-Jun-2013 00:30, Byron Heads пишет:
On Tue, 04 Jun 2013 13:15:07 -0700, 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.

but a compress interface would be nice:

interface Compress
{
     ubyte[] compress(ubyte[]);
     ubyte[] uncompress(ubyte[]);
}

that way you can use any compress algorithm
bool send(Compress)(Socket sock);


It's a range already thus composable. Ranged I/O though is something to come some time in near future (Steve?)

--
Dmitry Olshansky

Reply via email to