Hi, I hope some of you D gurus can help me getting my mind setup
correct when using D arrays.
I have an array: data[1 .. 2048] of type ubyte
I'm interested in getting the addresse of the array and its data
members. So I used:
writefln("adress data[%d] = %d", 0, &data);
writefln("adress data[
On Sun, 30 May 2010 21:43:16 +0200, Robert wrote:
> Hi, I hope some of you D gurus can help me getting my mind setup correct
> when using D arrays.
>
> I have an array: data[1 .. 2048] of type ubyte
>
> I'm interested in getting the addresse of the array and its data
> members. So I used:
>
> w
On 05/30/2010 09:43 PM, Robert wrote:
Hi, I hope some of you D gurus can help me getting my mind setup correct
when using D arrays.
I have an array: data[1 .. 2048] of type ubyte
I'm interested in getting the addresse of the array and its data
members. So I used:
writefln("adress data[%d] = %d
On 2010-05-30 21:50:10 +0200, Moritz Warning said:
try data.ptr instead of &data.
Ah, I was looking for something like this but didn't find it.
Do all variables and types support the .ptr property?
--
Robert M. Münch
http://www.robertmuench.de
On 2010-05-30 22:16:55 +0200, Pelle said:
&data[0] and &data are very different things, if you have a dynamic array.
Yes, that's what I found out too. What's the exact difference?
--
Robert M. Münch
http://www.robertmuench.de
Robert wrote:
Ah, I was looking for something like this but didn't find it.
Do all variables and types support the .ptr property?
Nope. Arrays do, as they are simply C arrays (T*) with a length
attached, and some fancy goings-on behind the scenes.
Basically, in C, the equivalent would be
t
Robert wrote:
On 2010-05-30 22:16:55 +0200, Pelle said:
&data[0] and &data are very different things, if you have a dynamic
array.
Yes, that's what I found out too. What's the exact difference?
Going again with the C code:
typedef struct array {
int* data;
int length;
};
You would
On 05/30/2010 11:00 PM, Robert wrote:
On 2010-05-30 22:16:55 +0200, Pelle said:
&data[0] and &data are very different things, if you have a dynamic
array.
Yes, that's what I found out too. What's the exact difference?
A dynamic array is a fat pointer with a length, approximately a struct
On 2010-05-30 23:12:06 +0200, "Simen kjaeraas" said:
Going again with the C code:
typedef struct array {
int* data;
int length;
};
You would use an array like this:
void foo( ) {
array arr;
arr.ptr = malloc(32);
arr.length = 8;
}
Now, as you can probbly see, &arr would giv
Robert wrote:
Ok, I thought that the structure was a bit more flat like:
typedef struct array {
int length;
int[1..length] data;
}
Avoiding one indirection as it could be assumed that the
memory-allocator / GC will return a continous piece for the array. But
of course resi
Hello robert,
But
of course resizing and reallocation would be a bit more complicated.
and it would make slicing impossible:
int[] a, b;
a.length = 10;
a[5] = 1;
b = a[5..10];
assert(b[0] == 1);
b[0] = 5;
assert(a[5] == 5);
--
... <
On 05/30/2010 11:54 PM, Robert wrote:
On 2010-05-30 23:12:06 +0200, "Simen kjaeraas"
said:
Going again with the C code:
typedef struct array {
int* data;
int length;
};
You would use an array like this:
void foo( ) {
array arr;
arr.ptr = malloc(32);
arr.length = 8;
}
Now, as you can probbl
12 matches
Mail list logo