Re: OpenGL in D2

2011-02-23 Thread Sequ
Quoted from Nrgyzer: On windows you've to create a folder called lib before you run the command above - I currently can't say it exactly if it's needed on linux, too. I did need to create a 'lib' directory before running 'make -flinux.mak DC=dmd'. After it compiled, you can copy all the

Re: Get n-th

2011-02-23 Thread bearophile
Jonathan M Davis: Assuming that it's a forward range rather than an input range: auto s = range.save; s.popFrontN(n - 1); writeln(s.front); This program gives: test.d(5): Error: no property 'popFrontN' for type 'Recurrence!(fun,int,2u)' import std.stdio, std.array, std.range; void main()

Re: Get n-th

2011-02-23 Thread Jonathan M Davis
On Wednesday 23 February 2011 04:34:28 bearophile wrote: Jonathan M Davis: Assuming that it's a forward range rather than an input range: auto s = range.save; s.popFrontN(n - 1); writeln(s.front); This program gives: test.d(5): Error: no property 'popFrontN' for type

Re: Get n-th

2011-02-23 Thread bearophile
Jonathan M Davis: Okay, so you need to do popFrontN(s, n - 1). Right, silly me :-) I need to read error messages. I'm too used to arrays which allow you to use that sort of syntax. Me too. Thank you, bye, bearophile

operator overloading?

2011-02-23 Thread %u
Hi everyone, Was hoping someone could help me make sense of this bit of C++ code: class canvas { operator HDC() { return _hdc; } protected: canvas(HDC hdc): _hdc(hdc) {} HDC _hdc; } From what I understand, HDC is an alias for HANDLE in Windows. So they are overloading canvas such

retrieving key and value type of an associative array (D1)

2011-02-23 Thread Funog
static if ( is(abc U : U[]) ) ... aliases U to whatever abc is an array of. In the case of an associative array, is it possible to retrieve both the value and key type? (D1)

Re: operator overloading?

2011-02-23 Thread Dmitry Olshansky
On 23.02.2011 17:08, %u wrote: Hi everyone, Was hoping someone could help me make sense of this bit of C++ code: class canvas { operator HDC() { return _hdc; } protected: canvas(HDC hdc): _hdc(hdc) {} HDC _hdc; } From what I understand, HDC is an alias for HANDLE in Windows.

Re: alias this for inheritance

2011-02-23 Thread Steven Schveighoffer
On Wed, 23 Feb 2011 10:34:04 -0500, spir denis.s...@gmail.com wrote: Hello, I have read several times that alias this is a way to implement inheritance for structs. I am simply unable to imagine how to use this feature that way. Has anyone an example? It allows *some* simulation of

Re: retrieving key and value type of an associative array (D1)

2011-02-23 Thread bearophile
Funog: In the case of an associative array, is it possible to retrieve both the value and key type? (D1) template AAKeyType(T) { alias typeof(T.keys[0]) AAKeyType; } template AAValType(T) { alias typeof(T.values[0]) AAValType; } Bye, bearophile

Re: operator overloading?

2011-02-23 Thread Simon
On 23/02/2011 14:37, Dmitry Olshansky wrote: On 23.02.2011 17:08, %u wrote: Hi everyone, Was hoping someone could help me make sense of this bit of C++ code: class canvas { operator HDC() { return _hdc; } protected: canvas(HDC hdc): _hdc(hdc) {} HDC _hdc; } From what I understand, HDC is an

Re: operator overloading?

2011-02-23 Thread Simon
On 23/02/2011 18:42, Simon wrote: On 23/02/2011 14:37, Dmitry Olshansky wrote: On 23.02.2011 17:08, %u wrote: Hi everyone, Was hoping someone could help me make sense of this bit of C++ code: class canvas { operator HDC() { return _hdc; } protected: canvas(HDC hdc): _hdc(hdc) {} HDC _hdc; }

Re: operator overloading?

2011-02-23 Thread Jonathan M Davis
On Wednesday, February 23, 2011 10:42:04 Simon wrote: On 23/02/2011 14:37, Dmitry Olshansky wrote: On 23.02.2011 17:08, %u wrote: Hi everyone, Was hoping someone could help me make sense of this bit of C++ code: class canvas { operator HDC() { return _hdc; } protected:

Re: operator overloading?

2011-02-23 Thread Dmitry Olshansky
On 23.02.2011 21:48, Simon wrote: On 23/02/2011 18:42, Simon wrote: On 23/02/2011 14:37, Dmitry Olshansky wrote: On 23.02.2011 17:08, %u wrote: Hi everyone, Was hoping someone could help me make sense of this bit of C++ code: class canvas { operator HDC() { return _hdc; } protected:

Re: operator overloading?

2011-02-23 Thread Simon
On 23/02/2011 19:56, Jonathan M Davis wrote: You can overload the cast operator in D: T opCast(T)() {...} but it's for explicit cast only. There is not currently any way to do implicit casts with an overloaded operator. You have to use alias this for that, which may or may not do what be

Re: OpenGL in D2

2011-02-23 Thread Nrgyzer
== Auszug aus Sequ (u...@example.net)'s Artikel Quoted from Nrgyzer: On windows you've to create a folder called lib before you run the command above - I currently can't say it exactly if it's needed on linux, too. I did need to create a 'lib' directory before running 'make - flinux.mak

Re: operator overloading?

2011-02-23 Thread %u
Thaks to everyone for your assistance.

What's wrong with this enum?

2011-02-23 Thread Andrej Mitrovic
// Works enum : int[string] { Circle = [CoolCircle:50] } // Error: non-constant expression [CoolCircle:50] enum shapes : int[string] { Circle = [CoolCircle:50] } I can't find this in bugzilla.

Re: What's wrong with this enum?

2011-02-23 Thread Jesse Phillips
Andrej Mitrovic Wrote: // Works enum : int[string] { Circle = [CoolCircle:50] } // Error: non-constant expression [CoolCircle:50] enum shapes : int[string] { Circle = [CoolCircle:50] } I can't find this in bugzilla. I believe it is because shapes.Circle[CoolCircle] =

Re: What's wrong with this enum?

2011-02-23 Thread Andrej Mitrovic
On 2/24/11, Jesse Phillips jessekphillip...@gmail.com wrote: I believe it is because shapes.Circle[CoolCircle] = 25; Huh? perhaps a a defining: enmu shapes : const(int[string]) would work? Nope. enumtwobug.d(10): Error: non-constant expression [CoolCircle:cast(const(int))50] Anyway

Re: What's wrong with this enum?

2011-02-23 Thread Andrej Mitrovic
I've tested on Ubuntu it still errors out.

Re: C++ to D: Help please

2011-02-23 Thread bearophile
%u: I am hoping that one of you experienced programmers out there could lend me a hand converting this small program to D. If you show specific problems some people here will try to help. But I think most people are not willing to translate a multi-module C++ program to D for you. If you

Additional path for libs

2011-02-23 Thread Heinz
Hey! May be a silly situation but i'm trying to append a search path for libraries from the command line. I'm running under win32 with DMD/OPTLINK and i use a batch file for compilation of my project. Adding the path to sc.ini won't help because the project' sources might be moving around in

Re: Additional path for libs

2011-02-23 Thread Andrej Mitrovic
See this: http://www.digitalmars.com/ctg/ctgLinkSwitches.html#scanlib You pass switches to the linker via -L, so the switch might be: dmd -L/SCANLIB Of course you would have to update the LIB environment variable in command line, or via a batch file before calling DMD: set

Re: Additional path for libs

2011-02-23 Thread Andrej Mitrovic
One more thing: If your lib files are relative to your current working directory, then you can just pass them to DMD. E.g. if your lib file is under the subdir folder of your current working dir you can just use: dmd main.d subdir\mylibfile.lib But maybe you knew that already.

std.xml empty element

2011-02-23 Thread Tom
Hi, how can I create an empty element with current D2 std.xml Element implementation? stdout.writeln(new Element(foo)); // Shields foo/foo instead of foo / Thanks in advance, Tom;

Re: std.xml empty element

2011-02-23 Thread Tom
Oops, I mean, yields :S El 24/02/2011 02:48, Tom escribió: Hi, how can I create an empty element with current D2 std.xml Element implementation? stdout.writeln(new Element(foo)); // Shields foo/foo instead of foo / Thanks in advance, Tom;

Re: C++ to D: Help please

2011-02-23 Thread %u
bearophile, You do have a point there, and I actually expected that response. I would have posted my attempt at implementation, but am unable to transfer info between the computer I'm typing this message on and the one I'm programming on at the moment. I have no problems converting small

Splitter.opSlice(), ranges and const strings

2011-02-23 Thread Christopher Bergqvist
Hi! I've run into an issue which I don't understand. Boiled down code: import std.regex; void main() { //string str = sdf; // works //const string str = sdf; // doesn't work immutable str = sdf; // doesn't work auto pat = regex(, *); auto split = splitter(str,

Re: Splitter.opSlice(), ranges and const strings

2011-02-23 Thread Jonathan M Davis
On Wednesday 23 February 2011 22:41:53 Christopher Bergqvist wrote: Hi! I've run into an issue which I don't understand. Boiled down code: import std.regex; void main() { //string str = sdf; // works //const string str = sdf; // doesn't work immutable str = sdf;