D with experimental features like tuple unpacking

bearophile bearophileHUGS at lycos.com
Tue Mar 26 06:14:37 PDT 2013


> Denis Shelomovskij:
>
>> D already have undocumented[1] front tuple expansion in 
>> foreach over range:
>> ---
>> import std.algorithm;
>> import std.stdio;
>>
>> void main() {
>>    enum s = "this is an example for huffman encoding"d;
>>    foreach (c, n; s.dup.sort().release().group())
>>        writefln("'%s'  %s", c, n);
>> }
>
>
> I know, but it doesn't work in the case of my code I have 
> shown, with a SortedRange of 2-tuples:
>
> void main() {
>     auto s = "this is an example for huffman encoding"d;
>     foreach (c, n; s.dup.sort().release.group.encode)
>         writefln("'%s'  %s", c, n);
> }


So I have suggested to remove that syntax and replace it with a 
syntax that is more explicit, more flexible and more general:

http://d.puremagic.com/issues/show_bug.cgi?id=9817

Bye,
bearophile


More information about the Digitalmars-d mailing list