interface final members

2012-02-21 Thread Joshua Reusch
interface I { final int foo(I other, int a, int b) { return other.foo(a,b) + a*b; } int foo(int a, int b); } class A : I { int foo(int a, int b) { return a*b; } } void main() { A a = new A; a.foo(5,5);

Re: float.nan is not itself ?

2012-02-14 Thread Joshua Reusch
Thank you for the explanation ! bearophile wrote: Joshua Reusch: why does this assertion fail: > assert(float.nan == float.nan); By design, the hardware that manages floating point numbers makes a NaN not equal to everything else, including other NaNs: http://en.wikipedia.org/wiki/

float.nan is not itself ?

2012-02-14 Thread Joshua Reusch
Hello, why does this assertion fail: > assert(float.nan == float.nan); there is the std.math.isNaN function which works correctly, but why can I not just use the comparison ? Thanks, Joshua

Re: Meaning of pure member function

2012-01-17 Thread Joshua Reusch
Am 17.01.2012 17:19, schrieb Jesse Phillips: On Tuesday, 17 January 2012 at 16:07:08 UTC, H. S. Teoh wrote: Do the current D compilers implement memoization? Not that I know of. dmd not, but phobos: http://dlang.org/phobos/std_functional.html#memoize But as a library implementation, it is

Re: Absolute beginner

2012-01-13 Thread Joshua Reusch
Am 13.01.2012 22:16, Piotr Szturmaj wrote: Jorge wrote: My first question si very silly: string str = readln() my input is for example 123 how can i convert this to an integer? import std.conv; // then in code: auto i = to!int(str); the string returned by readln() ends with NL ('\n'), w

Re: std.csv

2012-01-09 Thread Joshua Reusch
Am 09.01.2012 16:19, schrieb simendsjo: On 09.01.2012 16:05, Joshua Reusch wrote: Hello, I checked out the phobos git repo and found a std.csv module. Is it ready to use or should I stay to my own (but incomplete and whithout any "good" error messages) csv reading function ? Than

Re: How to get runtime args from shared static this module ctor?

2012-01-09 Thread Joshua Reusch
Am 09.01.2012 18:00, schrieb Andrej Mitrovic: I need to get the name of the executable but without using a string[] from main. I'm wrapping a 3rd party library that requires me to initialize it by calling an extern function to pass the executable name. However I don't want to force the user to p

std.csv

2012-01-09 Thread Joshua Reusch
Hello, I checked out the phobos git repo and found a std.csv module. Is it ready to use or should I stay to my own (but incomplete and whithout any "good" error messages) csv reading function ? Thank you

Re: Problem with Hiredis Binding

2012-01-05 Thread Joshua Reusch
Sure ? dlang.org says they are not: http://www.d-programming-language.org/arrays.html#strings Sorry, in the printf section: "String literals already have a 0 appended to them, so can be used directly" I missed this.

Re: Problem with Hiredis Binding

2012-01-05 Thread Joshua Reusch
Am 05.01.2012 19:44, schrieb Timon Gehr: On 01/05/2012 07:14 PM, Joshua Reusch wrote: Am 05.01.2012 17:21, schrieb Puming Zhao: Hi, I'm new in D programming, and does not have much C experience either. After reading TDPL book and playing with some sample codes, I came to decide t

Re: Problem with Hiredis Binding

2012-01-05 Thread Joshua Reusch
Am 05.01.2012 17:21, schrieb Puming Zhao: Hi, I'm new in D programming, and does not have much C experience either. After reading TDPL book and playing with some sample codes, I came to decide to try something more `practical`. I began with a Redis client binding from Hiredis C code. Hiredis is

Re: rvalue references template ?

2012-01-02 Thread Joshua Reusch
Am 02.01.2012 22:13, schrieb Simen Kjærås: On Mon, 02 Jan 2012 15:02:30 +0100, Joshua Reusch wrote: Is it possible to create a template turning any value into a lvalue? This would be helpful if a function expects a reference but you dont need the result of the change: ///decode(S)(in S str

rvalue references template ?

2012-01-02 Thread Joshua Reusch
Is it possible to create a template turning any value into a lvalue? This would be helpful if a function expects a reference but you dont need the result of the change: ///decode(S)(in S str, ref size_t index); auto c = std.utf.decode(some_string, lval!0);

Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern

2011-12-25 Thread Joshua Reusch
Am 25.12.2011 22:37, schrieb Tal: I want to save the hInstance of WinMain so I would be able to use it later in some other module. So how do I accomplish that ? If you don't know: You can also get the HINSTANCE with GetModuleHandle(NULL);

Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern

2011-12-25 Thread Joshua Reusch
Am 25.12.2011 23:26, schrieb Tal: I'm quite new to this language, could you please provide a short snippet of code to clarify ? --- a.d: import std.stdio; import b; void main() { writeln("some_var from Module b: \"", b.some_var, "\""); } --- b.d: public string some_var = "Hello, world!";

Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern

2011-12-25 Thread Joshua Reusch
Am 25.12.2011 22:37, schrieb Tal: I want to save the hInstance of WinMain so I would be able to use it later in some other module. So how do I accomplish that ? just define a public variable in the global scope.

Re: Alias/Ref Tuples ?

2011-12-16 Thread Joshua Reusch
Am 17.12.2011 01:23, schrieb Simen Kjærås: On Fri, 16 Dec 2011 14:00:11 +0100, Joshua Reusch wrote: Hello, is there a way to say something like --- int a, b; AliasTuple!(a, b) = tuple(4,5); assert(a == 4 && b == 5); --- without having to write an own AliasTuple template ? I want t

Re: Alias/Ref Tuples ?

2011-12-16 Thread Joshua Reusch
I found a way doing this with a simple function: --- void explode(R, T...)(R range, ref T values) { static if(hasLength!R) assert(range.length == T.length); foreach(i, value; range) values[i] = value; } --- but a more self-documenting version would be nice.

Alias/Ref Tuples ?

2011-12-16 Thread Joshua Reusch
Hello, is there a way to say something like --- int a, b; AliasTuple!(a, b) = tuple(4,5); assert(a == 4 && b == 5); --- without having to write an own AliasTuple template ? I want to use it for functions returning multiple values. Joshua Reusch