January 30, 2011 General » Re: structs vs classes | |||
|---|---|---|---|
| |||
...RAII. classes are reference types with inheritance and polymorphism. They don't really support RAII... | |||
January 27, 2011 General » Re: Is D still alive? | |||
|---|---|---|---|
| |||
...to learn D. The main reasons were RAII and Design by Contract. Even funnier, it... | |||
January 26, 2011 General » Re: destructor order | |||
|---|---|---|---|
| |||
...use clear() you will have to enforce RAII using structs (not garbage collected) or finally... | |||
January 23, 2011 Learn » Re: How to use structs for RAII? | |||
|---|---|---|---|
| |||
Ah, I keep forgetting about opCall. Nice tips there. | |||
January 23, 2011 Learn » Re: How to use structs for RAII? | |||
|---|---|---|---|
| |||
A static opCall would be better. See my answer to the original post. -- /Jacob Carlborg | |||
January 23, 2011 Learn » Re: How to use structs for RAII? | |||
|---|---|---|---|
| |||
You can use a static opCall, like this:
struct Foo
{
static Foo opCall ()
{
Foo foo... | |||
January 23, 2011 Learn » Re: How to use structs for RAII? | |||
|---|---|---|---|
| |||
The typical thing to do when you want a default constructor for a struct is... | |||
January 23, 2011 Learn » Re: Garbage-collected structs vs garbage-collected classes | |||
|---|---|---|---|
| |||
...believe that they work properly for normal RAII), but in particular, for the moment, don... | |||
January 23, 2011 Learn » Re: How to use structs for RAII? | |||
|---|---|---|---|
| |||
Actually this becomes rather annoying, since I can't use any closures on the object... | |||
January 23, 2011 Learn » Re: How to use structs for RAII? | |||
|---|---|---|---|
| |||
A workaround:
import std.stdio;
import std.exception;
struct A
{
int x;
this(void* none... | |||
Copyright © 1999-2021 by the D Language Foundation