Initialization of std.typecons.RefCounted objects

2012-07-18 Thread Matthias Walter
Hi, I looked at Bug #6153 (Array!(Array!int) failure) and found that the reason is the following behavior: Given some type T you wrap as RefCounted!T object, then proper use of the auto-initialization feature or manual initialization on demand ensures that no null-pointer dereference will happen.

Re: Initialization of std.typecons.RefCounted objects

2012-07-18 Thread Christophe Travert
Matthias Walter , dans le message (digitalmars.D:172673), a écrit : > I looked at Bug #6153 (Array!(Array!int) failure) and found that the > > This exactly is what makes the following code fail: > > Array!(Array!int) array2d; > array2d.length = 1; > array2d[0].insert(1); > > The inner array "arra

Re: Initialization of std.typecons.RefCounted objects

2012-07-18 Thread Christophe Travert
I see you found the appropriate entry to discuss this bug: http://d.puremagic.com/issues/show_bug.cgi?id=6153

Re: Initialization of std.typecons.RefCounted objects

2012-07-19 Thread Matthias Walter
On 07/18/2012 03:32 PM, Christophe Travert wrote: > Matthias Walter , dans le message (digitalmars.D:172673), a écrit : >> I looked at Bug #6153 (Array!(Array!int) failure) and found that the >> >> This exactly is what makes the following code fail: >> >> Array!(Array!int) array2d; >> array2d.lengt

Re: Initialization of std.typecons.RefCounted objects

2012-07-19 Thread monarch_dodra
On Wednesday, 18 July 2012 at 13:32:39 UTC, trav...@phare.normalesup.org (Christophe Travert) wrote: I think opIndex should return by reference. opIndexAssign is of no help when the user want to use a function that takes a reference (here Array.insert). Having already brought this up before,

Re: Initialization of std.typecons.RefCounted objects

2012-07-19 Thread Christophe Travert
"monarch_dodra" , dans le message (digitalmars.D:172700), a écrit : > I think it would be better to "initialize on copy", rather than > default initialize. There are too many cases an empty array is > created, then initialized on the next line, or passed to > something else that does the initial

Re: Initialization of std.typecons.RefCounted objects

2012-07-19 Thread Matthias Walter
On 07/19/2012 10:14 AM, Christophe Travert wrote: > "monarch_dodra" , dans le message (digitalmars.D:172700), a écrit : >> I think it would be better to "initialize on copy", rather than >> default initialize. There are too many cases an empty array is >> created, then initialized on the next lin

Re: Initialization of std.typecons.RefCounted objects

2012-07-19 Thread monarch_dodra
On Thursday, 19 July 2012 at 08:14:25 UTC, trav...@phare.normalesup.org (Christophe Travert) wrote: "monarch_dodra" , dans le message (digitalmars.D:172700), a écrit : I think it would be better to "initialize on copy", rather than default initialize. There are too many cases an empty array is

Re: Initialization of std.typecons.RefCounted objects

2012-07-19 Thread Christophe Travert
"monarch_dodra" , dans le message (digitalmars.D:172710), a écrit : > One of the reason the implementation doesn't let you escape a > reference is that that reference may become (_unverifiably_) > invalid. The same applies to a dynamic array: it is undistinguishable from a sliced static array.

Re: Initialization of std.typecons.RefCounted objects

2012-07-19 Thread Matthias Walter
On 07/19/2012 02:16 PM, Christophe Travert wrote: > "monarch_dodra" , dans le message (digitalmars.D:172710), a écrit : >> One of the reason the implementation doesn't let you escape a >> reference is that that reference may become (_unverifiably_) >> invalid. > > The same applies to a dynamic a