Re: Do constructors in D support the privacy keyword?

2013-09-08 Thread Michael
In same module private acts like friend in C++.

SpawnProcess fails when console is hidden

2013-09-08 Thread Nemo
Hi, I have win32 program, which takes command line parameters and passes them trough socket to another program, running on the same machine. If connection fails, it needs to start the another program. I don't want console to popup so I added -L/SUBSYSTEM:WINDOWS. This works fine, except

Re: Bug with multiple subtyping?

2013-09-08 Thread Joseph Rushton Wakeling
On 07/09/13 16:10, Joseph Rushton Wakeling wrote: TDPL gives a description in Section 6.13 (pp. 230-233) of a method for subtyping by storing a private instance of the base type and using alias ... this to access its methods. The example given is as follows: No one has confirmed yea or nay on

Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Gary Willoughby
When iterating through class members using traits how do you filter out the member vars to only get a list of methods. I think i've solved it in the code below but it feels like i am abusing MemberFunctionsTuple. Is this the correct way to do this? private template Methods(T, int index = 0) {

Re: Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Dicebot
Key part here is is(T == function) - because of D type system funny properties only possible way to get T that matches that condition is to do `typeof` from declared function/method symbol. That type can't be manually expressed and thus used for member variable.

Re: Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Dicebot
http://dpaste.dzfl.pl/c250e798 import std.traits, std.range; private template Methods(T) if (is(T == class)) { private string[] getMethods() { string result[]; foreach (member_string; __traits(allMembers, T))

Re: SpawnProcess fails when console is hidden

2013-09-08 Thread Adam D. Ruppe
My guess, just looking at it, is that spawnProcess fails because there's no streams available for stdin, stdout, and stderr. It tries to reuse the ones of the parent process, but without a console they don't work. It might help to use Config.suppressConsole.. I'm just guessing but maybe

Re: Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Gary Willoughby
On Sunday, 8 September 2013 at 13:46:26 UTC, Dicebot wrote: http://dpaste.dzfl.pl/c250e798 import std.traits, std.range; private template Methods(T) if (is(T == class)) { private string[] getMethods() { string result[];

Re: Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Dicebot
On Sunday, 8 September 2013 at 16:43:16 UTC, Gary Willoughby wrote: This looks like a nice solution but i get errors when used across modules. The problem is that allmembers emits private members so across modules they are not available. You want to list private members or want them ignored

Re: SpawnProcess fails when console is hidden

2013-09-08 Thread Nemo
Thank you, Config.suppressConsole did not help, but redirecting the std:s did.

Re: Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Gary Willoughby
On Sunday, 8 September 2013 at 17:07:57 UTC, Dicebot wrote: On Sunday, 8 September 2013 at 16:43:16 UTC, Gary Willoughby wrote: This looks like a nice solution but i get errors when used across modules. The problem is that allmembers emits private members so across modules they are not

Re: Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Adam D. Ruppe
Something along the lines of static if(__traits(compiles, __traits(getMember, Foo, member)) static if(is(__traits(getMember, Foo, member) == function)) { // use it } The __traits(compiles, ...) is my go-to thingy for filtering out random errors.

Re: Non-covariance and overrides

2013-09-08 Thread Jacob Carlborg
On 2013-09-07 13:42, Joseph Rushton Wakeling wrote: On 03/09/13 08:56, Jacob Carlborg wrote: class MyFakeSubclass { MyBaseClass base alias base this; } Every method not available in MyFakeSubclass will be forwarded to base. http://dlang.org/class.html#AliasThis OK, but the

Re: Bug with multiple subtyping?

2013-09-08 Thread Jacob Carlborg
On 2013-09-07 16:10, Joseph Rushton Wakeling wrote: Hello all, TDPL gives a description in Section 6.13 (pp. 230-233) of a method for subtyping by storing a private instance of the base type and using alias ... this to access its methods. The example given is as follows: class StorableShape :

Re: Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Jacob Carlborg
On 2013-09-08 18:43, Gary Willoughby wrote: This looks like a nice solution but i get errors when used across modules. The problem is that allmembers emits private members so across modules they are not available. I'm wondering if it tries to call the method here: static if

Re: Bug with multiple subtyping?

2013-09-08 Thread Joseph Rushton Wakeling
On 08/09/13 21:44, Jacob Carlborg wrote: Try using opDispatch as a described in the other thread. I'll give that a go, but I still think this is a bug that needs fixing. The example in TDPL p. 231 will very clearly also not work due to this issue.

Re: Using traits get a list of methods and filter out the member vars.

2013-09-08 Thread Dicebot
On Sunday, 8 September 2013 at 19:48:31 UTC, Jacob Carlborg wrote: I'm wondering if it tries to call the method here: static if (is(typeof(member) == function)) Since D allows to call methods without parentheses. No, not in typeof. It will try to call it with `member.stringof` though, thus

Limited type matching?

2013-09-08 Thread Namespace
Code: import std.stdio; void foo(short x, short y) { } void foo(short[2] xy) { } void main() { foo(1, 2); /// works foo([1, 2]); /// works ushort[2] xy = [1, 2]; foo(xy); /// fails ushort x = 1, y = 2; foo(x, y); /// works

Re: nothrow function to tell if a string can be converted to a number?

2013-09-08 Thread Timothee Cour
On Fri, Sep 6, 2013 at 9:38 PM, Jonathan M Davis jmdavisp...@gmx.comwrote: On Friday, September 06, 2013 21:15:44 Timothee Cour wrote: I'd like to have a function: @nothrow bool isNumberLitteral(string a); unittest{ assert(isNumberLitteral(1.2)); assert(!isNumberLitteral(a1.2));

Re: nothrow function to tell if a string can be converted to a number?

2013-09-08 Thread Timothee Cour
sorry I was a bit sloppy in my previous post. Here it is corrected: I was also curious whether there's functionality for the following (I wrote my own versions but they might not consider all cases) bool isStringLitteral(string); //tests whether a string represents a string litteral unittest{