Re: Rethrow an exception like in C++?

2013-03-07 Thread Jonathan M Davis
On Friday, March 08, 2013 08:08:48 Rob T wrote: > On Friday, 8 March 2013 at 06:05:02 UTC, Maxim Fomin wrote: > > Actually no. > > > > class myException1 : Exception { this() { super("1"); } } > > class myException2 : Exception { this() { super("2"); } } > > [...] > > Thanks! That solves 99% of

Re: Rethrow an exception like in C++?

2013-03-07 Thread Rob T
One more thing, we finally got __FUNCTION__ (and more) added to MASTER so that's another missing item that was sorely missed. Now we can easily log what functions are catching and throwing exceptions, and more. The big question is if Throwable will be expanded to automatically capture the fun

Re: Rethrow an exception like in C++?

2013-03-07 Thread Rob T
On Friday, 8 March 2013 at 06:09:48 UTC, Jonathan M Davis wrote: [...] C++ has no exception capabilities that D doesn't have. Except that D cannot rethrow without explicitly catching. That may seem like a very minor item, but as I explained in my last post, the extra boiler plate coding can a

Re: Rethrow an exception like in C++?

2013-03-07 Thread Rob T
On Friday, 8 March 2013 at 06:05:02 UTC, Maxim Fomin wrote: Actually no. class myException1 : Exception { this() { super("1"); } } class myException2 : Exception { this() { super("2"); } } [...] Thanks! That solves 99% of my problem. I wasn't aware that I could check the derived type from a

Re: Rethrow an exception like in C++?

2013-03-07 Thread Maxim Fomin
On Friday, 8 March 2013 at 05:46:48 UTC, Rob T wrote: That's very unfortunate, and should be corrected, because it means that you cannot easily catch multiple derived Exception types and rethrow the same derived type. Instead you have to explicitly catch all derived types and rethrow them indi

Re: Rethrow an exception like in C++?

2013-03-07 Thread Jonathan M Davis
On Friday, March 08, 2013 06:46:47 Rob T wrote: > That's very unfortunate, and should be corrected, because it > means that you cannot easily catch multiple derived Exception > types and rethrow the same derived type. Instead you have to > explicitly catch all derived types and rethrow them individ

Re: Rethrow an exception like in C++?

2013-03-07 Thread Rob T
On Friday, 8 March 2013 at 01:56:45 UTC, Andrej Mitrovic wrote: On 3/8/13, Rob T wrote: In C++, I rethrow an exception without explicitly catching it catch(...) { throw; } Anyone know of a way to do the same thing in D? catch { // rethrow? } The only way: try { } catch (Exception

Re: Rethrow an exception like in C++?

2013-03-07 Thread Andrej Mitrovic
On 3/8/13, Rob T wrote: > In C++, I rethrow an exception without explicitly catching it > > catch(...) > { > throw; > } > > Anyone know of a way to do the same thing in D? > > catch > { > // rethrow? > > } The only way: try { } catch (Exception ex) { throw ex; } Or use Error or Throwabl

Rethrow an exception like in C++?

2013-03-07 Thread Rob T
In C++, I rethrow an exception without explicitly catching it catch(...) { throw; } Anyone know of a way to do the same thing in D? catch { // rethrow? } --rt

Re: Why don't underscores in numbers enforce proper formatting?

2013-03-07 Thread Era Scarecrow
On Thursday, 7 March 2013 at 06:31:39 UTC, Simen Kjærås wrote: On Wed, 06 Mar 2013 22:06:42 +0100, ixid wrote: The underscores in values such as 1_000_000 aid readability but DMD doesn't see anything wrong with any placement of underscores as long as they follow a number. Is there any reaso

Re: question when writing to a file

2013-03-07 Thread lomereiter
Indeed, that shouldn't be the case. I filed a bug request: http://d.puremagic.com/issues/show_bug.cgi?id=9661 While it isn't fixed, assign file to a variable so that it doesn't go out of scope. On Thursday, 7 March 2013 at 16:20:24 UTC, bioinfornatics wrote: I only replace write by put and

Re: question when writing to a file

2013-03-07 Thread bioinfornatics
On Thursday, 7 March 2013 at 16:12:09 UTC, bioinfornatics wrote: On Thursday, 7 March 2013 at 13:37:56 UTC, lomereiter wrote: The second is probably faster (with optimizations enabled), because each call to writeln incurs overhead of locking/unlocking the file stream (which is stdout in this c

Re: question when writing to a file

2013-03-07 Thread bioinfornatics
On Thursday, 7 March 2013 at 13:37:56 UTC, lomereiter wrote: The second is probably faster (with optimizations enabled), because each call to writeln incurs overhead of locking/unlocking the file stream (which is stdout in this case). If you need to print huge amounts of data, use lockingTex

Re: wxD - dead or alive?

2013-03-07 Thread Raphaël Jakse
Le 07/03/2013 02:11, Matthew Caron a écrit : On 03/05/2013 08:18 AM, Matthew Caron wrote: On 03/04/2013 11:24 AM, SaltySugar wrote: On Monday, 4 March 2013 at 13:25:22 UTC, Matthew Caron wrote: On 03/03/2013 08:16 AM, SaltySugar wrote: wxD - dead or alive? I've been using it. What makes you

Re: question when writing to a file

2013-03-07 Thread lomereiter
The second is probably faster (with optimizations enabled), because each call to writeln incurs overhead of locking/unlocking the file stream (which is stdout in this case). If you need to print huge amounts of data, use lockingTextWriter like this: auto w = stdout.lockingTextWriter; foreach

Re: question when writing to a file

2013-03-07 Thread bearophile
bioinfornatics: I mean if one way is more efficient by speed? To be sure of what's faster you often have to write small benchmarks. In this case this should be good: import std.stdio, std.array; void main() { writefln("%-(%s\n%)", ["hello"].replicate(5)); } But if you want speed this

Re: Tid between classes

2013-03-07 Thread Jacob Carlborg
On 2013-03-07 11:07, Stephen Jones wrote: As far as I can see gtkD no longer supports openGL so I was thinking it might be possible to run a gtkD GUI on the main thread and openGL/Derelict on another. The Gl thread is derived; extends Thread. With threads having separate memory is this assumption

Tid between classes

2013-03-07 Thread Stephen Jones
As far as I can see gtkD no longer supports openGL so I was thinking it might be possible to run a gtkD GUI on the main thread and openGL/Derelict on another. The Gl thread is derived; extends Thread. With threads having separate memory is this assumption correct? If it is, I would like to us

question when writing to a file

2013-03-07 Thread bioinfornatics
Dear, little question when writing to a file 5 "hello" lines (by example) I would like to know if they are a difference between: writeln( "hello" ); x5 and: string[] helloList = [ "hello","hello","hello","hello","hello"]; writeln( helloList.join( newline) ); I mean if one way is more effic