the wrapper? `new int[]` isn't
supported, even though that's exactly what I want.
On Wednesday, 10 January 2018 at 22:35:01 UTC, Luís Marques wrote:
How can I do that without the wrapper? `new int[]` isn't
supported, even though that's exactly what I want.
Just to be extra clear: I really do want a normal D slice, it
can't be a fixed-length array.
;
writeln(context.x);
}
How can I do that without the wrapper? `new int[]` isn't supported, even
though that's exactly what I want.
If I understand correctly, the goal is to have the `int[]` itself on the
GC heap. You can make an `int[][]` with one element, and then take the
addre
Is there any problem with:
import std.stdio;
void main(string[] args)
{
int[] x = [1, 2, 3];
writeln(x);
}
https://run.dlang.io/is/CliWcz
On Wednesday, 10 January 2018 at 22:46:30 UTC, ag0aep6g wrote:
If I understand correctly, the goal is to have the `int[]`
itself on the GC heap.
General word of warning: if you pass it to C and the C function
holds on to that pointer for any reason beyond its immediate
execution, you could be
context = cast(Wrapper*) ctxptr;
writeln(context.x);
}
How can I do that without the wrapper? `new int[]` isn't supported,
even though that's exactly what I want.
If I understand correctly, the goal is to have the `int[]` itself on the
GC heap. You can make an `int[][]
On Wednesday, 10 January 2018 at 22:46:30 UTC, ag0aep6g wrote:
If I understand correctly, the goal is to have the `int[]`
itself on the GC heap.
The code
void main(string[] args) @nogc
{
int[] x = [1, 2, 3];
}
won't compile, because "array literal in @nogc function 'D main'
may
On Wednesday, 10 January 2018 at 22:48:48 UTC, Adam D. Ruppe
wrote:
General word of warning: if you pass it to C and the C function
holds on to that pointer for any reason beyond its immediate
execution, you could be looking at a problem because the D GC
can't see C function memory and may free
On Wednesday, 10 January 2018 at 22:46:30 UTC, ag0aep6g wrote:
If I understand correctly, the goal is to have the `int[]`
itself on the GC heap.
That's correct.
You can make an `int[][]` with one element, and then take the
address of that element:
void main()
{
int[]* x = &[[1, 2, 3]][0
On Wednesday, January 10, 2018 22:50:22 Nathan S. via Digitalmars-d-learn
wrote:
> On Wednesday, 10 January 2018 at 22:46:30 UTC, ag0aep6g wrote:
> > If I understand correctly, the goal is to have the `int[]`
> > itself on the GC heap.
>
> The code
>
> void main(string[] args) @nogc
> {
>
On Wednesday, 10 January 2018 at 23:08:28 UTC, Luís Marques wrote:
void main()
{
int[]* x = &[[1, 2, 3]][0];
int[]* x2 = [[1, 2, 3]].ptr; /* same */
}
That's an interesting solution. I'm not sure which one I
prefer, the wrapper or this one. Still... I feel like the
language should just
is there any different b/w:
auto arr = new int[10];
and
int[10] arr;
?
%u wrote:
is there any different b/w:
auto arr = new int[10];
arr is dynamic array of int with ten elements
and
int[10] arr;
?
arr is static array of int with ten elements
13 matches
Mail list logo