Here's a simple solution. Just make Bar a pointer and free it
before it can be destructed!
import std.stdio;
struct Bar {
~this() {
writeln("~bar");
}
}
struct Foo {
Bar *bar;
this(int why_the_fuck_dont_structs_have_default_constructors)
{
bar = new Bar;
Here's a simple solution. Just make Bar a pointer and free it
before it can be destructed!
import std.stdio;
struct Bar {
~this() {
writeln("~bar");
}
}
struct Foo {
Bar *bar;
this(int why_the_fuck_dont_structs_have_default_constructors)
{
bar = new Bar;
On Wednesday, 27 September 2017 at 23:24:58 UTC, user1234 wrote:
On Wednesday, 27 September 2017 at 21:01:36 UTC, Jesse Phillips
wrote:
On Wednesday, 27 September 2017 at 16:35:54 UTC, DreadKyller
wrote:
My question is about overloading, several operators can be
overloaded in D, one of the
On Wednesday, 27 September 2017 at 21:01:36 UTC, Jesse Phillips
wrote:
On Wednesday, 27 September 2017 at 16:35:54 UTC, DreadKyller
wrote:
My question is about overloading, several operators can be
overloaded in D, one of the ones that can't apparently is the
address of operator (). My
On Wednesday, 27 September 2017 at 14:34:06 UTC, Eugene Wissner
wrote:
On Wednesday, 27 September 2017 at 14:23:01 UTC, Ky-Anh Huynh
wrote:
See also the following chapter in Ali's book:
http://ddili.org/ders/d.en/templates.html
This chapter is what hooked me with D. Naming that chapter as
On Wednesday, 27 September 2017 at 17:58:27 UTC, Ali Çehreli
wrote:
On 09/27/2017 08:33 AM, Ky-Anh Huynh wrote:
> [...]
Wissner wrote:
> [...]
The fact that such an important operator is explained so late
in the book is due to the book's strong desire to have a linear
flow.
[...]
ustad,
On 09/27/2017 03:06 PM, Mengu wrote:
ustad, guess you can still write the new ed. :-)
Since you're still around, one of these days... :)
Ali
On Wednesday, 27 September 2017 at 21:18:50 UTC, nkm1 wrote:
On Wednesday, 27 September 2017 at 20:24:24 UTC, DreadKyller
wrote:
The attitude of "some people use this feature incorrectly, so
let's ban it's use entirely" is honestly ridiculous to me, but
oh well, that's apparently the modern
On Wednesday, 27 September 2017 at 21:44:48 UTC, Ali Çehreli
wrote:
On 09/27/2017 02:39 PM, timvol wrote:
[...]
void main() {
auto mem = new ubyte[1024+15];
auto ptr = cast(ubyte*)(cast(ulong)(mem.ptr + 15) &
~0x0FUL);
auto arr = ptr[0..1024];
}
Ali
Works perfect. Thank you!
On 09/27/2017 02:39 PM, timvol wrote:
Hi guys,
how can I allocate an (e.g. 16) byte aligned array?
In C I can do the following:
void *mem = malloc(1024+15);
void *ptr = ((uintptr_t)mem+15) & ~ (uintptr_t)0x0F;
memset_16aligned(ptr, 0, 1024);
free(mem);
I think in D it looks
Hi guys,
how can I allocate an (e.g. 16) byte aligned array?
In C I can do the following:
void *mem = malloc(1024+15);
void *ptr = ((uintptr_t)mem+15) & ~ (uintptr_t)0x0F;
memset_16aligned(ptr, 0, 1024);
free(mem);
I think in D it looks similar to this:
auto mem = new
On Wednesday, 27 September 2017 at 20:24:24 UTC, DreadKyller
wrote:
The attitude of "some people use this feature incorrectly, so
let's ban it's use entirely" is honestly ridiculous to me, but
oh well, that's apparently the modern philosophy.
Not even modern, see Java :) ("I left out operator
On Wednesday, 27 September 2017 at 21:01:36 UTC, Jesse Phillips
wrote:
For example, if you store your Matrix in a custom container it
could try to store pointer rather than the struct itself, if &
is overloaded the generic implementation would be broken
because it would no longer be a pointer
On Wednesday, 27 September 2017 at 16:35:54 UTC, DreadKyller
wrote:
My question is about overloading, several operators can be
overloaded in D, one of the ones that can't apparently is the
address of operator (). My question is have I simply
missed it or does it actually not exist, and if it's
On Wednesday, 27 September 2017 at 19:55:07 UTC, nkm1 wrote:
On Wednesday, 27 September 2017 at 16:35:54 UTC, DreadKyller
wrote:
Been using D for a couple years now, however one problem I've
had, more so recently since I've been dealing a lot with
OpenGL is related to pointers.
I have a
On Wednesday, 27 September 2017 at 16:35:54 UTC, DreadKyller
wrote:
Been using D for a couple years now, however one problem I've
had, more so recently since I've been dealing a lot with OpenGL
is related to pointers.
I have a matrix object to aid with the matrix math required for
working
At
https://github.com/nordlow/phobos-next/blob/03b4736fdd65ef84c6fc583eddee4196629cea81/src/variant_arrays.d
I've implemented a lightweight-polymorphic array container I call
`VariantArrays(Types...)` indexed by a corresponding polymorphic
index I call `VariantIndex(Types...)`.
It uses
On 09/27/2017 08:33 AM, Ky-Anh Huynh wrote:
> On Wednesday, 27 September 2017 at 14:34:06 UTC, Eugene Wissner wrote:
>>
>> See also the following chapter in Ali's book:
>> http://ddili.org/ders/d.en/templates.html
>
> Thanks a lot. I will keep reading :)
The fact that such an important operator
Been using D for a couple years now, however one problem I've
had, more so recently since I've been dealing a lot with OpenGL
is related to pointers.
I have a matrix object to aid with the matrix math required for
working with 3D transforms. However OpenGL (I'm using DerelictGL3
bindings)
On Wednesday, 27 September 2017 at 10:05:34 UTC, Nicholas Wilson
wrote:
I'd just use dirEntries with SpanMode.shallow in combination
with filter either in a loop or a recursive function like below.
void foo(string path = "path")
{
foreach(e;
On Wednesday, 27 September 2017 at 14:23:01 UTC, Ky-Anh Huynh
wrote:
Can you please explain and give any link where I can learn more
about these things?
Thanks a lot.
http://nomad.so/2013/07/templates-in-d-explained/
On Wednesday, 27 September 2017 at 14:34:06 UTC, Eugene Wissner
wrote:
See also the following chapter in Ali's book:
http://ddili.org/ders/d.en/templates.html
Thanks a lot. I will keep reading :)
On Wednesday, 27 September 2017 at 14:23:01 UTC, Ky-Anh Huynh
wrote:
Hi,
I am from Ruby world where I can have `!` (or `?`) in method
names: `!` indicates that a method would modify its object
(`foo.upcase!` means `foo = foo.upcase`). ( I don't know if
there is any official Ruby
There are two types of arguments in D. The runtime one (which you are
well aware of) and the compile time one. A compile time argument is a
constant passed in during construction of a symbol.
But here is the thing, it isn't just limited to functions, you can have
it on classes as well.
---
Hi,
I am from Ruby world where I can have `!` (or `?`) in method
names: `!` indicates that a method would modify its object
(`foo.upcase!` means `foo = foo.upcase`). ( I don't know if there
is any official Ruby documentation on this convention though. )
In D I see `!` quite a lot. I have
GCC supports a `__attribute((section("...")))` for variables to
put them in specific sections in the final assembly. Is there any
way this can be achieved in D? Does GDC support this?
On Wednesday, 27 September 2017 at 09:00:55 UTC, Ky-Anh Huynh
wrote:
Hi,
Can I have a `break` option when using `dirEntries()` (similar
to `break` in a loop)? I want to study sub-directories but if
any sub-directory matches my criteria I don't to look further
into their subdirectories
```
Hi,
Can I have a `break` option when using `dirEntries()` (similar
to `break` in a loop)? I want to study sub-directories but if any
sub-directory matches my criteria I don't to look further into
their subdirectories
```
A/ -> matches criteria, stop here, go to next directory (B)
28 matches
Mail list logo