Re: Using std.stdio.File in a class

2014-04-08 Thread Adam D. Ruppe
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

Using std.stdio.File in a class

2014-04-08 Thread Spacen Jasset
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() {

Re: Using std.stdio.File in a class

2014-04-08 Thread Spacen Jasset
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

Re: Using std.stdio.File in a class

2014-04-08 Thread Steven Schveighoffer
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.

Re: Using std.stdio.File in a class

2014-04-08 Thread Rene Zwanenburg
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

Re: Using std.stdio.File in a class

2014-04-08 Thread monarch_dodra
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.

Re: Using std.stdio.File in a class

2014-04-08 Thread Spacen Jasset
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

Re: Using std.stdio.File in a class

2014-04-08 Thread Spacen Jasset
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

Re: Using std.stdio.File in a class

2014-04-08 Thread Adam D. Ruppe
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.

Re: Using std.stdio.File in a class

2014-04-08 Thread Steven Schveighoffer
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