Re: D with experimental features like tuple unpacking

2013-03-26 Thread bearophile
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);

Re: D with experimental features like tuple unpacking

2013-03-22 Thread Dmitry Olshansky
22-Mar-2013 17:41, renoX пишет: The fact that you sort of can't easily index tuple of 3 ints as a fixed array of 3 ints is a clear indication of a tendency that I find disturbing. But there is a reason for this: tuple/structs can contain heterogeneous type whereas array contains only homogeneou

Re: D with experimental features like tuple unpacking

2013-03-22 Thread Tobias Pankrath
On Friday, 22 March 2013 at 14:23:53 UTC, Tobias Pankrath wrote: But there is a reason for this: tuple/structs can contain heterogeneous type whereas array contains only homogeneous type.. So if you want to index a tuple/struct of say {int,int[128]} you have to build an array of pointers to t

Re: D with experimental features like tuple unpacking

2013-03-22 Thread Tobias Pankrath
On Friday, 22 March 2013 at 13:41:31 UTC, renoX wrote: The fact that you sort of can't easily index tuple of 3 ints as a fixed array of 3 ints is a clear indication of a tendency that I find disturbing. But there is a reason for this: tuple/structs can contain heterogeneous type whereas array

Re: D with experimental features like tuple unpacking

2013-03-22 Thread renoX
The fact that you sort of can't easily index tuple of 3 ints as a fixed array of 3 ints is a clear indication of a tendency that I find disturbing. But there is a reason for this: tuple/structs can contain heterogeneous type whereas array contains only homogeneous type.. So if you want to inde

Re: D with experimental features like tuple unpacking

2013-03-22 Thread Dmitry Olshansky
22-Mar-2013 16:44, renoX пишет: On Friday, 22 March 2013 at 11:14:47 UTC, Dmitry Olshansky wrote: I'd hate any solution that distances ordinary structs, library tuples and fixed-sized arrays. Are struct/tuples similar to fixed-sized array? I thought that both are different because you can sele

Re: D with experimental features like tuple unpacking

2013-03-22 Thread renoX
On Friday, 22 March 2013 at 11:14:47 UTC, Dmitry Olshansky wrote: I'd hate any solution that distances ordinary structs, library tuples and fixed-sized arrays. Are struct/tuples similar to fixed-sized array? I thought that both are different because you can select which element you access at r

Re: D with experimental features like tuple unpacking

2013-03-22 Thread Dmitry Olshansky
22-Mar-2013 15:25, bearophile пишет: Dmitry Olshansky: auto (lof, loa) = ...; In Haskell, Scala, Python, F#, etc, the semantics and syntax are similar. I'd hate any solution that distances ordinary structs, library tuples and fixed-sized arrays. If anything these should be trivially substit

Re: D with experimental features like tuple unpacking

2013-03-22 Thread ixid
foreach ((c, ref e); loa) I think parens become rather confusing, what about something like: foreach (|c, ref e|; loa)

Re: D with experimental features like tuple unpacking

2013-03-22 Thread bearophile
Dmitry Olshansky: auto (lof, loa) = ...; In Haskell, Scala, Python, F#, etc, the semantics and syntax are similar. I'd hate any solution that distances ordinary structs, library tuples and fixed-sized arrays. If anything these should be trivially substitutable where makes sense. In Bug

Re: D with experimental features like tuple unpacking

2013-03-22 Thread John Colvin
On Friday, 22 March 2013 at 07:05:03 UTC, Denis Shelomovskij wrote: 22.03.2013 1:13, bearophile пишет: And in foreach: foreach ((c, ref e); loa) D already have undocumented[1] front tuple expansion in foreach over range: --- import std.algorithm; import std.stdio; void main() { enum s

Re: D with experimental features like tuple unpacking

2013-03-22 Thread Dmitry Olshansky
22-Mar-2013 14:58, bearophile пишет: Jacob Carlborg: auto (lof, loa) = heap.front; How is front suddenly returning two elements? It is not returning two elements. In D you can't return two elements. It is returning a 2-Tuple. You see the 2-tuples are built by the map() and then used to cr

Re: D with experimental features like tuple unpacking

2013-03-22 Thread bearophile
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,

Re: D with experimental features like tuple unpacking

2013-03-22 Thread Jacob Carlborg
On 2013-03-21 22:13, bearophile wrote: auto (lof, loa) = heap.front; How is front suddenly returning two elements? -- /Jacob Carlborg

Re: D with experimental features like tuple unpacking

2013-03-22 Thread Dmitry Olshansky
22-Mar-2013 11:05, Denis Shelomovskij пишет: 22.03.2013 1:13, bearophile пишет: And in foreach: foreach ((c, ref e); loa) 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 f

Re: D with experimental features like tuple unpacking

2013-03-22 Thread Denis Shelomovskij
22.03.2013 1:13, bearophile пишет: And in foreach: foreach ((c, ref e); loa) 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

Re: D with experimental features like tuple unpacking

2013-03-21 Thread Rob T
I would like to see tuple syntax and abilities improved. It's been a while since I last tried to use them so I'm not prepared to explain in detail what I'd like to see for improvements, however I can say that when I did try to use them I remember they were much more unwieldy to use and more lim

D with experimental features like tuple unpacking

2013-03-21 Thread bearophile
UFCS, plus some tweaks to the standard library like this one (http://d.puremagic.com/issues/show_bug.cgi?id=8755 ) help write D code in a more functional (flow programming, Walter calls it component programming) style. So tuples become more and more useful, and the lack of a syntax to unpack