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[] +
No, vibe provides synchronous non-blocking interface similar to
async/await.
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[];
Operations like ar1[] op= ar2[] op ar3[] is only for arrays.
There is no operator overloading for this staff.
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
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[] =
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
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
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.
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
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
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
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
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
14 matches
Mail list logo