Re: initialization immutable array

2014-05-16 Thread bearophile via Digitalmars-d
monarch_dodra: That's also why I've stopped using "writeln()" as UFCS: It "looks" convenient at first, but then you want to turn those "writeln" into "writefln", and that's when things don't go according to plan... Yes, I understand. If you want some ugly code you can use std.functional.bi

Re: initialization immutable array

2014-05-16 Thread monarch_dodra via Digitalmars-d
On Friday, 16 May 2014 at 08:43:31 UTC, bearophile wrote: monarch_dodra: UFCS iota :puke: I think UFCS iota is acceptable when it has only one argument: myArray.length.iota... Bye, bearophile My gripe is how "incompatible" 1-arg and 2-arg iota is w.r.t. UFCS: 0.iota(4); 4.iota(); That

Re: initialization immutable array

2014-05-16 Thread Jacob Carlborg via Digitalmars-d
On 16/05/14 10:32, monarch_dodra wrote: UFCS iota :puke: Yeah, it would make more sense if it would be called "upto": 1.upto(4) -- /Jacob Carlborg

Re: initialization immutable array

2014-05-16 Thread bearophile via Digitalmars-d
monarch_dodra: UFCS iota :puke: I think UFCS iota is acceptable when it has only one argument: myArray.length.iota... Bye, bearophile

Re: initialization immutable array

2014-05-16 Thread monarch_dodra via Digitalmars-d
On Friday, 16 May 2014 at 06:37:30 UTC, Jacob Carlborg wrote: import std.algorithm; import std.range; immutable(int[]) _items = 1.iota(4).array; UFCS iota :puke:

Re: initialization immutable array

2014-05-15 Thread Jacob Carlborg via Digitalmars-d
On 15/05/14 18:13, AntonSotov wrote: DMD 2.065 I do not know much English. sorry. need to initialize immutable array "_items" //--- module main; import std.stdio; class Zond { this() { foreach (i; 1..4) { _items ~= i; // is ex

Re: initialization immutable array

2014-05-15 Thread Ali Çehreli via Digitalmars-d
On 05/15/2014 11:18 AM, AntonSotov wrote: if this is actually a bug - will be good if someone could register it. Done: https://issues.dlang.org/show_bug.cgi?id=12749 Ali

Re: initialization immutable array

2014-05-15 Thread Steven Schveighoffer via Digitalmars-d
On Thu, 15 May 2014 14:18:03 -0400, AntonSotov wrote: On Thursday, 15 May 2014 at 17:15:50 UTC, Steven Schveighoffer wrote: Assign _items only once in the constructor. immutable(int)[] tmp; foreach(i; 1..4) tmp ~= i; _items = tmp; thanks for example! On Thursday, 15 May 2014 at 17:1

Re: initialization immutable array

2014-05-15 Thread AntonSotov via Digitalmars-d
On Thursday, 15 May 2014 at 17:15:50 UTC, Steven Schveighoffer wrote: Assign _items only once in the constructor. immutable(int)[] tmp; foreach(i; 1..4) tmp ~= i; _items = tmp; thanks for example! On Thursday, 15 May 2014 at 17:15:50 UTC, Steven Schveighoffer wrote: This should not wor

Re: initialization immutable array

2014-05-15 Thread Steven Schveighoffer via Digitalmars-d
On Thu, 15 May 2014 12:13:58 -0400, AntonSotov wrote: DMD 2.065 I do not know much English. sorry. need to initialize immutable array "_items" //--- module main; import std.stdio; class Zond { this() { foreach (i; 1..4) { _

Re: initialization immutable array

2014-05-15 Thread Yota via Digitalmars-d
On Thursday, 15 May 2014 at 16:13:59 UTC, AntonSotov wrote: DMD 2.065 I do not know much English. sorry. need to initialize immutable array "_items" //--- module main; import std.stdio; class Zond { this() { foreach (i; 1..4) { _i

initialization immutable array

2014-05-15 Thread AntonSotov via Digitalmars-d
DMD 2.065 I do not know much English. sorry. need to initialize immutable array "_items" //--- module main; import std.stdio; class Zond { this() { foreach (i; 1..4) { _items ~= i; // is expected ERROR } } immutable(int[]