Re: Partial classes

2012-01-30 Thread bls
On 01/29/2012 01:43 PM, Mars wrote: Hello everybody. Quick question, is there anything like C#'s partial classes in D? Mars As already said template mixins are close to partial classes. A snippet. HTH import std.stdio, std.cstream; void main(string[] args) { auto bar = new Bar();

combine different data type

2012-01-30 Thread sami
when i do that auto x = [1, ha]; i have an error Error: incompatible types for ((1) ? (hgh)): 'int' and 'string' if there any method to combine different data type?

Chained Catch Statements

2012-01-30 Thread Jared
In Java and C++, I can do something to the effect of: try { //Some code } catch (Exception1) { } catch (Exception2) { } //etc... However, this doesn't seem to be possible in D. What is the idiom for handling a case where multiple exceptions of different types may be thrown?

Re: Chained Catch Statements

2012-01-30 Thread Trass3r
What is the idiom for handling a case where multiple exceptions of different types may be thrown? I think you could catch a common baseclass like Exception and test if it's a specific Exception by casting.

Re: Chained Catch Statements

2012-01-30 Thread Adam D. Ruppe
On Monday, 30 January 2012 at 14:37:19 UTC, Jared wrote: In Java and C++, I can do something to the effect of: That works in D too. I believe it does it linearly though, so it will use the first catch that matches. try {} catch (Exception e) {} // most throwable objects derive from

Compile Time Printing

2012-01-30 Thread Blake Anderton
So from what I've found searching the newsgroup and my own experimentation, the best way to accomplish compile time printing is to do something like this: string ctMain() { //evaluate and return the final result string } enum result = ctMain(); pragma(msg, result); I'm not a fan of having

Re: Chained Catch Statements

2012-01-30 Thread Jared
I suppose that works, though it does seem a little hackish (and I'm pretty sure it's considered bad form in Java). What was the line of reasoning for omitting this (to me, at least) extremely useful construct?

Re: Chained Catch Statements

2012-01-30 Thread Mantis
30.01.2012 16:37, Jared пишет: However, this doesn't seem to be possible in D. Why not? import std.stdio; class Exception1 : Throwable { this( string s ) { super( s ); } } class Exception2 : Throwable { this( string s ) { super( s ); } } void foo() { throw new Exception1( foo ); } void

Re: combine different data type

2012-01-30 Thread Simen Kjærås
On Mon, 30 Jan 2012 13:58:38 +0100, sami s...@hotmail.com wrote: when i do that auto x = [1, ha]; i have an error Error: incompatible types for ((1) ? (hgh)): 'int' and 'string' if there any method to combine different data type? You might want to check out std.variant. It's Variant type

sub() in D2?

2012-01-30 Thread adamss3
Is there a direct analog to sub() in D2? The replace() function in regex seems a bit overkill for what I need. I just want to substitute one string for another.

Re: combine different data type

2012-01-30 Thread Daniel Murphy
Simen Kjærås simen.kja...@gmail.com wrote in message news:op.v8wj38qf0gp...@biotronic.lan... On Mon, 30 Jan 2012 13:58:38 +0100, sami s...@hotmail.com wrote: when i do that auto x = [1, ha]; i have an error Error: incompatible types for ((1) ? (hgh)): 'int' and 'string' if there any method

Re: sub() in D2?

2012-01-30 Thread Adam D. Ruppe
http://www.d-programming-language.org/phobos/std_array.html#replace import std.array; string a = test; string b = a.replace(t, p); assert(b == pesp);

Re: sub() in D2?

2012-01-30 Thread adamss3
Thanks.

RPC module for D ?

2012-01-30 Thread luis
There are any RPC module for D ??

Re: RPC module for D ?

2012-01-30 Thread David Nadlinger
On 1/30/12 5:27 PM, luis wrote: There are any RPC module for D ?? I implemented support for Apache Thrift during last summer's GSoC, it's currently under review for inclusion into Thrift trunk: http://klickverbot.at/code/gsoc/thrift/ David

Re: Chained Catch Statements

2012-01-30 Thread Alex Rønne Petersen
On 30-01-2012 15:37, Jared wrote: In Java and C++, I can do something to the effect of: try { //Some code } catch (Exception1) { } catch (Exception2) { } //etc... However, this doesn't seem to be possible in D. What is the idiom for handling a case where multiple exceptions of different

Re: Chained Catch Statements

2012-01-30 Thread Era Scarecrow
On Monday, 30 January 2012 at 14:50:23 UTC, Adam D. Ruppe wrote: On Monday, 30 January 2012 at 14:37:19 UTC, Jared wrote: In Java and C++, I can do something to the effect of: That works in D too. I believe it does it linearly though, so it will use the first catch that matches. try {}

Re: Chained Catch Statements

2012-01-30 Thread Andrej Mitrovic
On 1/30/12, Era Scarecrow rtcv...@yahoo.com wrote: To me this seems like a mistake. You could throw SpecialException in the handler for Exception. So it's legal code.

Re: Compile Time Printing

2012-01-30 Thread bearophile
Blake Anderton: I know a ctwriteln never really caught on, There is an open pull request about it. And I think we'll have it in D. A problem is, that ctwriteln too adds a newline... :-( Bye, bearophile

Re: Chained Catch Statements

2012-01-30 Thread Era Scarecrow
On Monday, 30 January 2012 at 17:17:46 UTC, Andrej Mitrovic wrote: On 1/30/12, Era Scarecrow rtcv...@yahoo.com wrote: To me this seems like a mistake. You could throw SpecialException in the handler for Exception. So it's legal code. Yes, thanks to inheritance it is legal code. However

Re: RPC module for D ?

2012-01-30 Thread Jacob Carlborg
On 2012-01-30 17:27, luis wrote: There are any RPC module for D ?? The Mango project has some support for RPC. But this if for D1 with Tango: http://dsource.org/projects/mango -- /Jacob Carlborg

Re: Chained Catch Statements

2012-01-30 Thread Jesse Phillips
On Monday, 30 January 2012 at 18:23:56 UTC, Era Scarecrow wrote: try { } catch (Throwable t) { } catch {Exception e) { //never executed } catch (StreamException st) { //never executed } //and the list can go on forever. See the problem? No? Error: catch at test.d(3) hides catch at

Re: Chained Catch Statements

2012-01-30 Thread Era Scarecrow
On Monday, 30 January 2012 at 19:25:03 UTC, Jesse Phillips wrote: On Monday, 30 January 2012 at 18:23:56 UTC, Era Scarecrow wrote: try { } catch (Throwable t) { } catch {Exception e) { //never executed } catch (StreamException st) { //never executed } //and the list can go on forever. See

Re: RPC module for D ?

2012-01-30 Thread Zardoz
I will try it. I only need to make a remote hello world , do a short description , and compare with other RPCs in other 3 languages (university homework...) . On Mon, 30 Jan 2012 17:30:59 +0100, David Nadlinger wrote: On 1/30/12 5:27 PM, luis wrote: There are any RPC module for D ?? I

Re: Pure Contract bug? (unnecessarily strict)

2012-01-30 Thread Jesse Phillips
On Sunday, 29 January 2012 at 06:22:26 UTC, Era Scarecrow wrote: Maybe someone's brought this up, but i seem to have the compiler complaining to me that my function isn't 'pure' by calling a non-pure function, specifically to!string(). I don't see why this couldn't be done, not only does it

Re: Pure Contract bug? (unnecessarily strict)

2012-01-30 Thread Era Scarecrow
I don't see why this couldn't be done, not only does it get not exist in release, it shouldn't be changing variables in non-release. As mentioned there is a hole for debug code. Report it: http://d.puremagic.com/issues/ and we'll see what happens with that. Reported; Minor priority (Won't

Re: RPC module for D ?

2012-01-30 Thread Zardoz
On Mon, 30 Jan 2012 17:30:59 +0100, David Nadlinger wrote: On 1/30/12 5:27 PM, luis wrote: There are any RPC module for D ?? I implemented support for Apache Thrift during last summer's GSoC, it's currently under review for inclusion into Thrift trunk:

Re: sub() in D2?

2012-01-30 Thread Marco Leise
Am 30.01.2012, 16:57 Uhr, schrieb adamss3 sadam...@woh.rr.com: Thanks. The only downside of strings being arrays: a lot of typical string functions are in std.array. :D

Re: RPC module for D ?

2012-01-30 Thread David Nadlinger
On 1/30/12 11:35 PM, Zardoz wrote: I try to build it and when i did make check to see it all works I get two fails : […] Oh, I'm afraid you caught me in a bad moment – because the version for upstream integration is frozen at Thrift's JIRA, I've been a bit more careless with multi-platform

Re: RPC module for D ?

2012-01-30 Thread Zardoz
On Tue, 31 Jan 2012 00:17:18 +0100, David Nadlinger wrote: On 1/30/12 11:35 PM, Zardoz wrote: I try to build it and when i did make check to see it all works I get two fails : […] Oh, I'm afraid you caught me in a bad moment – because the version for upstream integration is frozen at

Re: RPC module for D ?

2012-01-30 Thread David Nadlinger
On 1/31/12 12:29 AM, Zardoz wrote: At least I can say that the Tutorial client server works (async_client not compile) :) . For me it's enough . Because you don't have libevent installed (the tutorial makefile doesn't have detection for that by design), or do you encounter another error?

Re: Chained Catch Statements

2012-01-30 Thread Andrej Mitrovic
On 1/30/12, Era Scarecrow rtcv...@yahoo.com wrote: If the compiler reorders the blocks for you A warning, maybe. But I'm against compilers which try to be too smart and rewrite code to change its semantics. If there's something wrong with my code I want to know about it (warning or error) and

Re: Chained Catch Statements

2012-01-30 Thread Jonathan M Davis
On Tuesday, January 31, 2012 01:05:20 Andrej Mitrovic wrote: On 1/30/12, Era Scarecrow rtcv...@yahoo.com wrote: If the compiler reorders the blocks for you A warning, maybe. But I'm against compilers which try to be too smart and rewrite code to change its semantics. If there's something

Re: Chained Catch Statements

2012-01-30 Thread bearophile
Jonathan M Davis: I do think that having the compiler complain when one catch block hides another makes a lot of sense, but I think that that's as far as it should go. It's the programmer's job to fix their code, not the compiler's. I agree. Do we create a new diagnostic enhancement request

About to!int

2012-01-30 Thread bearophile
In Python int() and float() convert a string into a number even if it contains some whitespace before and after the number: s = 12\n int(s) 12 float(s) 12.0 In D to!int( 12\n) gives a run-time error. So time ago I have weakly asked Andrei to change to!int, to let it ignore leading and

Re: Chained Catch Statements

2012-01-30 Thread Era Scarecrow
I see no reason why the compiler should be reordering anything here. That changes the semantics of the code. It's not like it's a great burden on the programmer to just reorder the blocks so that they're in the correct order. Having the compiler give a warning or error would be plenty, and a

Re: sub() in D2?

2012-01-30 Thread Jacob Carlborg
On 2012-01-31 00:09, Marco Leise wrote: Am 30.01.2012, 16:57 Uhr, schrieb adamss3 sadam...@woh.rr.com: Thanks. The only downside of strings being arrays: a lot of typical string functions are in std.array. :D If everything in std.array works for strings as well, shouldn't std.string

Re: sub() in D2?

2012-01-30 Thread Jonathan M Davis
On Tuesday, January 31, 2012 08:16:25 Jacob Carlborg wrote: On 2012-01-31 00:09, Marco Leise wrote: Am 30.01.2012, 16:57 Uhr, schrieb adamss3 sadam...@woh.rr.com: Thanks. The only downside of strings being arrays: a lot of typical string functions are in std.array. :D If everything

Re: About to!int

2012-01-30 Thread Zardoz
On Mon, 30 Jan 2012 21:01:38 -0500, bearophile wrote: In D to!int( 12\n) gives a run-time error. So time ago I have weakly asked Andrei to change to!int, to let it ignore leading and trailing whitespace, but he has ignored my request. A leading newline comes often from input