Re: Implicit static-dynamic arr and modifying

2014-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
On 5/6/2014 6:46 PM, Rene Zwanenburg wrote: On Tuesday, 6 May 2014 at 02:17:06 UTC, Nick Sabalausky wrote: So all is well, and deliberately so. Pardon the noise. IMO it's not. I once had a particularly nasty bug because of this: struct S { @safe: string str; this(string data)

Re: Implicit static-dynamic arr and modifying

2014-05-07 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 07, 2014 at 06:31:15PM +, Rene Zwanenburg via Digitalmars-d-learn wrote: On Wednesday, 7 May 2014 at 15:41:19 UTC, Nick Sabalausky wrote: On 5/6/2014 6:46 PM, Rene Zwanenburg wrote: [...] struct S { @safe: string str; this(string data) { import

Re: Implicit static-dynamic arr and modifying

2014-05-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Mon, 05 May 2014 22:16:58 -0400 Nick Sabalausky via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 5/5/2014 10:11 PM, Nick Sabalausky wrote: Is this kinds stuff a sane thing to do, or does it just work by accident?: void modify(ubyte[] dynamicArr) {

Re: Implicit static-dynamic arr and modifying

2014-05-06 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, May 06, 2014 at 01:06:14AM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: On Mon, 05 May 2014 22:16:58 -0400 Nick Sabalausky via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 5/5/2014 10:11 PM, Nick Sabalausky wrote: Is this kinds stuff a sane thing to

Re: Implicit static-dynamic arr and modifying

2014-05-06 Thread bearophile via Digitalmars-d-learn
H. S. Teoh: Exercise for the reader: spot the bug. https://issues.dlang.org/show_bug.cgi?id=5212 https://issues.dlang.org/show_bug.cgi?id=11657 Bye, bearophile

Re: Implicit static-dynamic arr and modifying

2014-05-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 6 May 2014 at 02:17:06 UTC, Nick Sabalausky wrote: So all is well, and deliberately so. Pardon the noise. IMO it's not. I once had a particularly nasty bug because of this: struct S { @safe: string str; this(string data) {

Implicit static-dynamic arr and modifying

2014-05-05 Thread Nick Sabalausky via Digitalmars-d-learn
Is this kinds stuff a sane thing to do, or does it just work by accident?: void modify(ubyte[] dynamicArr) { dynamicArr[$-1] = 5; } void main() { ubyte[4] staticArr = [1,1,1,1]; modify(staticArr); assert(staticArr == [1,1,1,5]); }

Re: Implicit static-dynamic arr and modifying

2014-05-05 Thread Nick Sabalausky via Digitalmars-d-learn
On 5/5/2014 10:11 PM, Nick Sabalausky wrote: Is this kinds stuff a sane thing to do, or does it just work by accident?: void modify(ubyte[] dynamicArr) { dynamicArr[$-1] = 5; } void main() { ubyte[4] staticArr = [1,1,1,1]; modify(staticArr); assert(staticArr == [1,1,1,5]);