Re: Dynamic array creation with default

2011-08-24 Thread Timon Gehr
On 08/24/2011 11:19 PM, Steven Schveighoffer wrote: On Wed, 24 Aug 2011 15:15:54 -0400, Michel Fortin wrote: On 2011-08-24 11:17:08 +, "Steven Schveighoffer" said: It's actually possible, but ugly: auto ptr = (new int[10][](1)).ptr; One really interesting thing to note -- the compiler a

Re: Dynamic array creation with default

2011-08-24 Thread Steven Schveighoffer
On Wed, 24 Aug 2011 15:15:54 -0400, Michel Fortin wrote: On 2011-08-24 11:17:08 +, "Steven Schveighoffer" said: It's actually possible, but ugly: auto ptr = (new int[10][](1)).ptr; One really interesting thing to note -- the compiler actually turns struct allocations into array-

Re: Dynamic array creation with default

2011-08-24 Thread Michel Fortin
On 2011-08-24 11:17:08 +, "Steven Schveighoffer" said: It's actually possible, but ugly: auto ptr = (new int[10][](1)).ptr; One really interesting thing to note -- the compiler actually turns struct allocations into array-of-one allocations in the runtime. So this is likely what the

Re: Dynamic array creation with default

2011-08-24 Thread Steven Schveighoffer
On Tue, 23 Aug 2011 10:45:33 -0400, Andrei Alexandrescu wrote: On 8/23/11 6:15 AM, foobar wrote: == Quote from bearophile (bearophileh...@lycos.com)'s article foobar: you raise a valid concern but this looks too complicated. I'd suggest to simplify into only two cases. // 1) T.INIT - as y

Re: Dynamic array creation with default

2011-08-23 Thread Andrei Alexandrescu
On 8/23/11 12:32 PM, Don wrote: foobar wrote: == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article On 8/23/11 6:15 AM, foobar wrote: == Quote from bearophile (bearophileh...@lycos.com)'s article foobar: you raise a valid concern but this looks too complicated. I'd sugg

Re: Dynamic array creation with default

2011-08-23 Thread Adam D. Ruppe
Don wrote: > Please note that moving AAs from built-in to library was little > short of a disaster, as far as the compiler is concerned. Amen. The library AAs *still* give me trouble from time to time - been the most buggy thing I've used in D.

Re: Dynamic array creation with default

2011-08-23 Thread Don
foobar wrote: == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article On 8/23/11 6:15 AM, foobar wrote: == Quote from bearophile (bearophileh...@lycos.com)'s article foobar: you raise a valid concern but this looks too complicated. I'd suggest to simplify into only two cas

Re: Dynamic array creation with default

2011-08-23 Thread Andrei Alexandrescu
On 8/23/11 8:11 AM, foobar wrote: == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article On 8/23/11 6:15 AM, foobar wrote: == Quote from bearophile (bearophileh...@lycos.com)'s article foobar: you raise a valid concern but this looks too complicated. I'd suggest to simpli

Re: Dynamic array creation with default

2011-08-23 Thread Lars T. Kyllingstad
On Tue, 23 Aug 2011 07:45:33 -0700, Andrei Alexandrescu wrote: > On 8/23/11 6:15 AM, foobar wrote: >> == Quote from bearophile (bearophileh...@lycos.com)'s article >>> foobar: you raise a valid concern but this looks too complicated. I'd suggest to simplify into only two cases.

Re: Dynamic array creation with default

2011-08-23 Thread bearophile
Andrei Alexandrescu: > I hate that, too. Walter hates it, too, but we both reckon it's too late > now to change things. With a soft deprecation path I think you will be able to deprecate and remove it in a year. Bye, bearophile

Re: Dynamic array creation with default

2011-08-23 Thread Timon Gehr
On 08/23/2011 05:11 PM, foobar wrote: == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article On 8/23/11 6:15 AM, foobar wrote: == Quote from bearophile (bearophileh...@lycos.com)'s article foobar: you raise a valid concern but this looks too complicated. I'd suggest to si

Re: Dynamic array creation with default

2011-08-23 Thread foobar
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article > On 8/23/11 6:15 AM, foobar wrote: > > == Quote from bearophile (bearophileh...@lycos.com)'s article > >> foobar: > >>> you raise a valid concern but this looks too complicated. > >>> I'd suggest to simplify into only two

Re: Dynamic array creation with default

2011-08-23 Thread foobar
== Quote from Timon Gehr (timon.g...@gmx.ch)'s article > On 08/23/2011 03:15 PM, foobar wrote: > > == Quote from bearophile (bearophileh...@lycos.com)'s article > >> foobar: > >>> you raise a valid concern but this looks too complicated. > >>> I'd suggest to simplify into only two cases. > >>> > >>

Re: Dynamic array creation with default

2011-08-23 Thread Andrei Alexandrescu
On 8/23/11 6:15 AM, foobar wrote: == Quote from bearophile (bearophileh...@lycos.com)'s article foobar: you raise a valid concern but this looks too complicated. I'd suggest to simplify into only two cases. // 1) T.INIT - as you suggested the dimension should be checked auto foo = new int[][](

Re: Dynamic array creation with default

2011-08-23 Thread Timon Gehr
On 08/23/2011 03:15 PM, foobar wrote: == Quote from bearophile (bearophileh...@lycos.com)'s article foobar: you raise a valid concern but this looks too complicated. I'd suggest to simplify into only two cases. // 1) T.INIT - as you suggested the dimension should be checked auto foo = new int[

Re: Dynamic array creation with default

2011-08-23 Thread foobar
== Quote from bearophile (bearophileh...@lycos.com)'s article > foobar: > > you raise a valid concern but this looks too complicated. > > I'd suggest to simplify into only two cases. > > > > // 1) T.INIT - as you suggested the dimension should be checked > > auto foo = new int[][](10, 20); // corre

Re: Dynamic array creation with default

2011-08-23 Thread bearophile
foobar: > you raise a valid concern but this looks too complicated. > I'd suggest to simplify into only two cases. > > // 1) T.INIT - as you suggested the dimension should be checked > auto foo = new int[][](10, 20); // correct > auto foo1 = new int[][](10); // compilation error Keep in mind tha

Re: Dynamic array creation with default

2011-08-23 Thread foobar
== Quote from bearophile (bearophileh...@lycos.com)'s article > To create a nD dynamic array and initialize it to a constant value (different from the init) you currently do something like this: > auto mat = new bool[][](10, 20); > foreach (ref row; mat) > row[] = true; > Currently this D code