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

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 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 than green (or vice versa). ;-) d

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 wrote: D string are actullay C-strings? in no way. only string *LITERALS* are zero-terminated. Ok. So I wrote the following: char c = *(

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 ketmar via Digitalmars-d-learn
On Sat, 13 Sep 2014 22:41:38 + AsmMan via Digitalmars-d-learn 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 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 wrote: I guess I was expecting them to be equivalent. I can understand why both lengths are zero. But what is emptyStr.ptr doing wit

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 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 so, what does > this address c

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 for

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[] =

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\Derelict>02_SimpleOpenGL_3_3_program.exe // object.Error: Access Violation // string

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: 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[]; asser

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.

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[] + d2[]

Template alias parameters to local variables

2014-09-13 Thread via Digitalmars-d-learn
Consider the following code: alias Sink = scope void delegate(const(char)[]); private template generateAliases(int __i, __vars...) { import std.conv : to; static if(__i < __vars.length) enum generateAliases = "alias " ~ __vars[__i].stringof ~ " =

Re: Why do 'abstract' methods with 'in' or 'out' contracts require a body?

2014-09-13 Thread bearophile via Digitalmars-d-learn
Marc Schütz: "Functions declared as abstract can still have function bodies. This is so that even though they must be overridden, they can still provide ‘base class functionality.’" => it's intentional But also they can not have. I don't think it's intentional. I think it's a temporary lim

Re: Why do 'abstract' methods with 'in' or 'out' contracts require a body?

2014-09-13 Thread KlausAlmaust via Digitalmars-d-learn
On Saturday, 13 September 2014 at 07:32:23 UTC, Marc Schütz wrote: On Saturday, 13 September 2014 at 05:07:32 UTC, Trey Brisbane wrote: Hey all, I have a class method defined like so: abstract class MyClass { public: @property abstract SomeClassType getField() pure nothrow

Re: Why do 'abstract' methods with 'in' or 'out' contracts require a body?

2014-09-13 Thread Trey Brisbane via Digitalmars-d-learn
On Saturday, 13 September 2014 at 07:32:23 UTC, Marc Schütz wrote: I thought it was an error, but then I found this in the documentation: http://dlang.org/attribute.html#abstract "Functions declared as abstract can still have function bodies. This is so that even though they must be overridde

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

2014-09-13 Thread Mike Parker via Digitalmars-d-learn
On 9/13/2014 7:44 AM, WhatMeWorry wrote: // the following two lines compile cleanly but when executed, I get // D:\Projects\Derelict>02_SimpleOpenGL_3_3_program.exe // object.Error: Access Violation // string glShadingLangVer = to!string(glGetString(GL_SHADING_LANGUAGE_VERSION)

Re: Why do 'abstract' methods with 'in' or 'out' contracts require a body?

2014-09-13 Thread via Digitalmars-d-learn
On Saturday, 13 September 2014 at 05:07:32 UTC, Trey Brisbane wrote: Hey all, I have a class method defined like so: abstract class MyClass { public: @property abstract SomeClassType getField() pure nothrow out(result) { assert(result !is null, "Error: ge