Re: Segmentation fault on closing file in destructor

2010-09-28 Thread Tom Kazimiers
Hi, On 09/27/2010 02:09 PM, Steven Schveighoffer wrote: > On Sun, 26 Sep 2010 20:20:18 -0400, Michel Fortin >> In fact, it's generally a good idea to not wait for the GC to collect >> your objects before closing files, because waiting for the GC could >> take an indeterminate amount of time and le

Re: Segmentation fault on closing file in destructor

2010-09-28 Thread Tom Kazimiers
Hi, On 09/26/2010 10:05 PM, Simen kjaeraas wrote: >>> Can you use scope(exit) or the std.stdio.File? >> >> Well, I have no idea. You mentioning scope(exit) was actually the first >> time I heard of it. Unfortunately I have not found any resource about >> it. Do you have a link to point me in the r

Re: Segmentation fault on closing file in destructor

2010-09-28 Thread Tom Kazimiers
Hi Jérôme, On 09/26/2010 10:59 PM, "Jérôme M. Berger" wrote: > The way I see it, there are two possible situations: > > 1. You really need precise control as to when the file is closed. In > that case, your class contains an explicit cleanup function that you > call before dropping the last

Re: Segmentation fault on closing file in destructor

2010-09-26 Thread Tom Kazimiers
Hi, On 09/26/2010 07:13 PM, bearophile wrote: > Tom Kazimiers: > >> Do you have any suggestion how I should make >> sure that the file gets closed on destruction? > > Can you use scope(exit) or the std.stdio.File? Well, I have no idea. You mentioning scope(exit) was a

Re: Segmentation fault on closing file in destructor

2010-09-26 Thread Tom Kazimiers
Hi Simen, On 09/26/2010 04:06 PM, Simen kjaeraas wrote: > Likely, it is this[1]: > > "[T]he order in which the garbage collector calls destructors for > unreference objects is not specified. This means that when the garbage > collector calls a destructor for an object of a class that has members

Segmentation fault on closing file in destructor

2010-09-26 Thread Tom Kazimiers
Hi, a file reading class of mine can be constructed with a filename as parameter. It instantiates a new std.stream.File (without the passed file name and closes it when opened within the destructor. The last part is where things are getting unclear for me. On the "file.isOpen()" call in the destru

Re: FIle I/O

2010-09-16 Thread Tom Kazimiers
Graham, On 09/16/2010 05:02 PM, Graham Nicholls wrote: > Is this D 1.0 ? I get errors regarding printf - I understood that writeln was > the > 2.0 way. Yes, I think it's D 1.0. For a D 2.0 version I replaced those printf's with writeln's, too. Bye, Tom

Re: FIle I/O

2010-09-16 Thread Tom Kazimiers
Hi Graham, On 09/16/2010 04:28 PM, Graham Nicholls wrote: > I'm writing a program to take a file and convert it into a binary format which > matches the format produced by a system which we use. If I get it right, this > will allow me to "replay" the file into the system. However I can't find ho

Re: Convert strings with different format to float

2010-09-08 Thread Tom Kazimiers
On 09/08/2010 06:58 PM, Stanislav Blinov wrote: > 08.09.2010 20:46, Tom Kazimiers wrote: >> Great! I am looking forward to that release :-). Any idea when it will >> be available? >> >> For the mean time I will, as proposed, make a separate function that >> chec

Re: Convert strings with different format to float

2010-09-08 Thread Tom Kazimiers
Hi, On 09/08/2010 10:02 AM, Stanislav Blinov wrote: >> I would have thought that to!float() could handle a number without a >> decimal point. If it can't I would suggest creating a bug report for >> it. Now, since such a fix would not help you immediately in either >> case, I would suggest creatin

Re: Convert strings with different format to float

2010-09-08 Thread Tom Kazimiers
Hi, On 09/08/2010 05:38 PM, Don wrote: > Pelle wrote: >> On 09/08/2010 09:23 AM, Tom Kazimiers wrote: >>> [ ..] >>> Maybe a to!float that can cope with >>> numbers without decimal point. >> >> You seem to have found a bug in to!float :-) >>

Convert strings with different format to float

2010-09-08 Thread Tom Kazimiers
Hi, I try to read data in from a file. This data consist mainly of numbers and I have a hard time converting it to number type variables. Two data lines could look like this v 0 0 0 v 1.5 1.2 0 Now I want to parse those lines and call a method, the line in passed (as char[]) to it: int index =

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread Tom Kazimiers
Hi, thanks for your tests. On 09/06/2010 04:59 AM, bearophile wrote: > My first test shows that it may work. But I have to grow the array > backwards, and push back the array start, because that's how my stack > grows (using alloca to allocate geometrically bigger chunks). So > unless you want to

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread Tom Kazimiers
> > Passing dynamic arrays to functions passes the reference. Thanks for your clarification and examples, that made the whole array handling clearer to me. On 09/07/2010 02:56 PM, Steven Schveighoffer wrote: > On Sun, 05 Sep 2010 22:41:50 -0400, bearophile wrote: >> Tom Kazimiers: &g

Fast temporary dynamic arrays? (And slicing of them)

2010-09-05 Thread Tom Kazimiers
Hi all, so I have started to look at D and dug through the documentation, but could not get a good answer on the following: How can I have a (temporary) dynamic array on stack and make references to it (no copying)? I successively put integers in an array (but don't know how much there will be in