Error: array operation d1[] + d2[] without assignment not implemented

2014-09-13 Thread deed via Digitalmars-d-learn
struct Vector (T) { T[]arr; void opSliceAssign (T[] a) { arr[] = a[]; } } unittest { auto v = Vector!double([1, 2]); double[] d1 = [11, 12]; double[] d2 = [21, 22]; double[] d3 = new double[](2); d3[] = d1[] + d2[]; assert (d3 == [11.+21., 12.+22.]); assert (is(typeof(d1[] +

Re: Idiomatic async programming like C# async/await

2014-09-13 Thread Kagamin via Digitalmars-d-learn
No, vibe provides synchronous non-blocking interface similar to async/await.

Re: Error: array operation d1[] + d2[] without assignment not implemented

2014-09-13 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Saturday, 13 September 2014 at 14:18:57 UTC, deed wrote: struct Vector (T) { T[]arr; void opSliceAssign (T[] a) { arr[] = a[]; } } unittest { auto v = Vector!double([1, 2]); double[] d1 = [11, 12]; double[] d2 = [21, 22]; double[] d3 = new double[](2); d3[] = d1[] + d2[];

Re: Error: array operation d1[] + d2[] without assignment not implemented

2014-09-13 Thread Ilya Yaroshenko via Digitalmars-d-learn
Operations like ar1[] op= ar2[] op ar3[] is only for arrays. There is no operator overloading for this staff.

Re: Should dmd have given me a warning at least?

2014-09-13 Thread WhatMeWorry via Digitalmars-d-learn
On Saturday, 13 September 2014 at 08:09:15 UTC, Mike Parker wrote: On 9/13/2014 7:44 AM, WhatMeWorry wrote: // the following two lines compile cleanly but when executed, I get // D:\Projects\Derelict02_SimpleOpenGL_3_3_program.exe // object.Error: Access Violation // string

Re: Error: array operation d1[] + d2[] without assignment not implemented

2014-09-13 Thread deed via Digitalmars-d-learn
Hi! struct Vector (T) { T[]arr; T[] opSlice() { return arr; } } Vector!double v; double[] d; v[][] = d[] + d[]; //first [] call opSlise, second [] for array syntax Best Regards, Ilya Thanks for your suggestion. It's not as attractive though, it would be the same as v.arr[] =

String Theory Questions

2014-09-13 Thread WhatMeWorry via Digitalmars-d-learn
The name string is aliased to immutable(char)[] Why was immutable chosen? Why not mutable. Or why not just make another alias called strung where it is aliased to mutable(char)[] Also, since strings are arrays and arrays are structs with a length and ptr field, I ran the following code

Re: String Theory Questions

2014-09-13 Thread ketmar via Digitalmars-d-learn
On Sat, 13 Sep 2014 17:09:56 + WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I guess I was expecting them to be equivalent. I can understand why both lengths are zero. But what is emptyStr.ptr doing with the 42F080 value? I presume this is a address? If

Re: String Theory Questions

2014-09-13 Thread AsmMan via Digitalmars-d-learn
On Saturday, 13 September 2014 at 17:31:18 UTC, ketmar via Digitalmars-d-learn wrote: On Sat, 13 Sep 2014 17:09:56 + WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I guess I was expecting them to be equivalent. I can understand why both lengths are zero.

Re: String Theory Questions

2014-09-13 Thread ketmar via Digitalmars-d-learn
On Sat, 13 Sep 2014 22:41:38 + AsmMan via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: D string are actullay C-strings? in no way. only string *LITERALS* are zero-terminated. signature.asc Description: PGP signature

Re: String Theory Questions

2014-09-13 Thread David Nadlinger via Digitalmars-d-learn
On Saturday, 13 September 2014 at 22:41:39 UTC, AsmMan wrote: D string are actullay C-strings? No. But string *literals* are guaranteed to be 0-terminated for easier interoperability with C code. David

Re: String Theory Questions

2014-09-13 Thread WhatMeWorry via Digitalmars-d-learn
On Saturday, 13 September 2014 at 23:22:40 UTC, ketmar via Digitalmars-d-learn wrote: On Sat, 13 Sep 2014 22:41:38 + AsmMan via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: D string are actullay C-strings? in no way. only string *LITERALS* are zero-terminated. Ok. So I

Re: String Theory Questions

2014-09-13 Thread ketmar via Digitalmars-d-learn
On Sun, 14 Sep 2014 00:34:54 + WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: So is one form (Empty strings versus null strings) considered better than the other? Or does it depend on the context? one is better than another in the sense that blue is better

Re: String Theory Questions

2014-09-13 Thread Ali Çehreli via Digitalmars-d-learn
On 09/13/2014 05:34 PM, WhatMeWorry wrote: aren't all strings literals? Literals are values that are typed as is in source code: http://en.wikipedia.org/wiki/Literal_%28computer_programming%29 Ali