On Tuesday, 8 April 2014 at 14:52:02 UTC, Spacen Jasset wrote:
Are you not supposed to new structs anymore?
Only if they're pointers. new File returns a File*, not a File.
But you shouldn't new a File because then the file won't be
automatically closed when it goes out of scope (RAII
I am trying to use file in a class. It doesn't seem to work. File
is a struct. Are you not supposed to new structs anymore? The
examples seem to use auto, but that isn't going to work in this
situation.
Is File a struct to take advantage of Raii?
import std.stdio;
class X
{
this()
{
On Tuesday, 8 April 2014 at 14:53:56 UTC, Adam D. Ruppe wrote:
On Tuesday, 8 April 2014 at 14:52:02 UTC, Spacen Jasset wrote:
Are you not supposed to new structs anymore?
Only if they're pointers. new File returns a File*, not a File.
But you shouldn't new a File because then the file won't
On Tue, 08 Apr 2014 10:52:01 -0400, Spacen Jasset
spacenjas...@mailrazer.com wrote:
I am trying to use file in a class. It doesn't seem to work. File is a
struct. Are you not supposed to new structs anymore? The examples seem
to use auto, but that isn't going to work in this situation.
On Tuesday, 8 April 2014 at 15:08:17 UTC, Spacen Jasset wrote:
On Tuesday, 8 April 2014 at 14:53:56 UTC, Adam D. Ruppe wrote:
On Tuesday, 8 April 2014 at 14:52:02 UTC, Spacen Jasset wrote:
Are you not supposed to new structs anymore?
Only if they're pointers. new File returns a File*, not a
On Tuesday, 8 April 2014 at 15:18:20 UTC, Steven Schveighoffer
wrote:
Just a word of caution, I don't think the RAII semantics of
File work properly in multithreaded code when the File is
destroyed by the GC.
-Steve
RAII doesn't work correctly with GC, period.
On Tuesday, 8 April 2014 at 15:15:37 UTC, Rene Zwanenburg wrote:
On Tuesday, 8 April 2014 at 15:08:17 UTC, Spacen Jasset wrote:
On Tuesday, 8 April 2014 at 14:53:56 UTC, Adam D. Ruppe wrote:
On Tuesday, 8 April 2014 at 14:52:02 UTC, Spacen Jasset wrote:
Are you not supposed to new structs
On Tuesday, 8 April 2014 at 15:18:20 UTC, Steven Schveighoffer
wrote:
On Tue, 08 Apr 2014 10:52:01 -0400, Spacen Jasset
spacenjas...@mailrazer.com wrote:
I am trying to use file in a class. It doesn't seem to work.
File is a struct. Are you not supposed to new structs anymore?
The examples
On Tuesday, 8 April 2014 at 15:52:23 UTC, Spacen Jasset wrote:
scope Stream file = new File(filename);
That's a std.stream.File which is a class (implementing the
Stream interface) which is a different animal from
std.stdio.File, which is a struct.
On Tue, 08 Apr 2014 11:54:45 -0400, Spacen Jasset
spacenjas...@mailrazer.com wrote:
On Tuesday, 8 April 2014 at 15:18:20 UTC, Steven Schveighoffer wrote:
Just a word of caution, I don't think the RAII semantics of File work
properly in multithreaded code when the File is destroyed by the
10 matches
Mail list logo