Re: 64 bit size_t

2014-02-17 Thread Kapps
On Monday, 17 February 2014 at 07:46:02 UTC, Steve Teale wrote: On Monday, 17 February 2014 at 07:17:06 UTC, Steve Teale wrote: What is size_t for 64 bit? Steve Sorry parent.children is just a straightforward array Sorry again - forget about it. I'd forgotten that D actually says int is

Re: Optimize my code =)

2014-02-17 Thread Robin
Hiho, I currently haven't got enough time to respond to all what have been said since my last post. However, here is the simple code: http://dpaste.dzfl.pl/3df8694eb47d Thanks in advance! I am really looking forward to your editing! =) Robin

Re: Optimize my code =)

2014-02-17 Thread John Colvin
On Monday, 17 February 2014 at 09:48:49 UTC, Robin wrote: Hiho, I currently haven't got enough time to respond to all what have been said since my last post. However, here is the simple code: http://dpaste.dzfl.pl/3df8694eb47d Thanks in advance! I am really looking forward to your editing!

Timer

2014-02-17 Thread Chris
The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every hour. if (file.older than 1 hour) { remove; }

Re: Timer

2014-02-17 Thread Chris
On Monday, 17 February 2014 at 11:11:06 UTC, simendsjo wrote: On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every hour. if (file.older than 1 hour) { remove; } Vibe.d

Re: Optimize my code =)

2014-02-17 Thread bearophile
Robin: http://dpaste.dzfl.pl/3df8694eb47d I think it's better to improve your code iteratively. First starting with small simple things: this(size_t rows, size_t cols) nothrow pure { = this(in size_t rows, in size_t cols) nothrow pure { this(ref const(Dimension) that)

Re: Timer

2014-02-17 Thread simendsjo
On Monday, 17 February 2014 at 11:20:05 UTC, Chris wrote: On Monday, 17 February 2014 at 11:11:06 UTC, simendsjo wrote: On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every

Re: Timer

2014-02-17 Thread Chris
On Monday, 17 February 2014 at 11:20:05 UTC, Chris wrote: On Monday, 17 February 2014 at 11:11:06 UTC, simendsjo wrote: On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every

Re: Timer

2014-02-17 Thread David
Am 17.02.2014 12:20, schrieb Chris: On Monday, 17 February 2014 at 11:11:06 UTC, simendsjo wrote: On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every hour. if (file.older

Re: Timer

2014-02-17 Thread Dejan Lekic
On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every hour. if (file.older than 1 hour) { remove; } Here is a quick timer implementation that you can improve yourself:

[video tutorial] Implementing a simple number guessing game

2014-02-17 Thread simendsjo
http://youtu.be/2Co65Ftxfdo

Re: [video tutorial] Implementing a simple number guessing game

2014-02-17 Thread simendsjo
On Monday, 17 February 2014 at 13:42:28 UTC, Dicebot wrote: On Monday, 17 February 2014 at 13:35:34 UTC, simendsjo wrote: http://youtu.be/2Co65Ftxfdo Slightly OT: hm, does D have own YouTube community channel? I'd subscribe to one ;) I don't think so. The closest is Andrei Alexandrescus

Re: [video tutorial] Implementing a simple number guessing game

2014-02-17 Thread Rikki Cattermole
On Monday, 17 February 2014 at 13:42:28 UTC, Dicebot wrote: On Monday, 17 February 2014 at 13:35:34 UTC, simendsjo wrote: http://youtu.be/2Co65Ftxfdo Slightly OT: hm, does D have own YouTube community channel? I'd subscribe to one ;) I'm working towards a channel specifically [0]. It will

Re: [video tutorial] Implementing a simple number guessing game

2014-02-17 Thread simendsjo
On Monday, 17 February 2014 at 14:00:06 UTC, Rikki Cattermole wrote: On Monday, 17 February 2014 at 13:42:28 UTC, Dicebot wrote: On Monday, 17 February 2014 at 13:35:34 UTC, simendsjo wrote: http://youtu.be/2Co65Ftxfdo Slightly OT: hm, does D have own YouTube community channel? I'd

Re: [video tutorial] Implementing a simple number guessing game

2014-02-17 Thread Rikki Cattermole
On Monday, 17 February 2014 at 14:04:45 UTC, simendsjo wrote: Sounds good, but I think a common channel for everything D would be a better move. A dlang channel that includes every talk, tutorial etc. I don't know much of how YouTube works, so I don't know if such an aggregated channel is

Re: [video tutorial] Implementing a simple number guessing game

2014-02-17 Thread Dicebot
I was thinking about one that would have an official status, linked from dlang.org main page and aggregates all community contributions in a single feed. Is there anyone willing to champion one? :) (I probably can but is far from my daily concerns) I am pretty sure no one will object such

Re: [video tutorial] Implementing a simple number guessing game

2014-02-17 Thread Dicebot
On Monday, 17 February 2014 at 14:08:10 UTC, Rikki Cattermole wrote: On Monday, 17 February 2014 at 14:04:45 UTC, simendsjo wrote: Sounds good, but I think a common channel for everything D would be a better move. A dlang channel that includes every talk, tutorial etc. I don't know much of how

Re: [video tutorial] Implementing a simple number guessing game

2014-02-17 Thread Rikki Cattermole
On Monday, 17 February 2014 at 14:06:00 UTC, Dicebot wrote: I was thinking about one that would have an official status, linked from dlang.org main page and aggregates all community contributions in a single feed. Is there anyone willing to champion one? :) (I probably can but is far from my

Re: [video tutorial] Implementing a simple number guessing game

2014-02-17 Thread Rikki Cattermole
On Monday, 17 February 2014 at 14:13:03 UTC, Dicebot wrote: There is no reason why official channel ust be focused on advanced and complicated stuff. Quite the contrary. I'd expect it to aggregate all stuff of sold quality - and nothing prevents video from being both in your dedicated channel

Re: Timer

2014-02-17 Thread Chris
On Monday, 17 February 2014 at 12:03:39 UTC, Dejan Lekic wrote: On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every hour. if (file.older than 1 hour) { remove; } Here

Re: Ranges, constantly frustrating

2014-02-17 Thread Regan Heath
This turned into a bit of a full spec so I would understand if you TL;DR but it would be nice to get some feedback if you have the time.. On Fri, 14 Feb 2014 17:34:46 -, bearophile bearophileh...@lycos.com wrote: Regan Heath: In my case I didn't need any of these. I don't

Re: foreach/iota countdown

2014-02-17 Thread Timon Gehr
On 02/17/2014 08:22 PM, simendsjo wrote: Should the following two uses be a compile-time error? foreach(i; 10 .. 0) // Never executes foreach(i; iota(10, 0)) // .. neither does this I would like the second to either be a compile-time error or automagically use a negative step. So we

Re: foreach/iota countdown

2014-02-17 Thread simendsjo
On Monday, 17 February 2014 at 19:30:38 UTC, Timon Gehr wrote: On 02/17/2014 08:22 PM, simendsjo wrote: Should the following two uses be a compile-time error? foreach(i; 10 .. 0) // Never executes foreach(i; iota(10, 0)) // .. neither does this I would like the second to either be a

Re: Hide console of gui program coded by gtkD

2014-02-17 Thread HSTI_SAURAV
On Monday, 10 December 2012 at 13:34:51 UTC, December Flower wrote: Hello. I have a question about how to hide a console window. http://pds23.egloos.com/pds/201212/10/80/e0088180_50c5e3b1bb789.png This simple application is made by using gtkD and glade3. As you can see from picture above,

foreach/iota countdown

2014-02-17 Thread simendsjo
Should the following two uses be a compile-time error? foreach(i; 10 .. 0) // Never executes foreach(i; iota(10, 0)) // .. neither does this I would like the second to either be a compile-time error or automagically use a negative step. So we need to use a negative step in iota() or use

Re: foreach/iota countdown

2014-02-17 Thread Timon Gehr
On 02/17/2014 08:33 PM, simendsjo wrote: On Monday, 17 February 2014 at 19:30:38 UTC, Timon Gehr wrote: On 02/17/2014 08:22 PM, simendsjo wrote: Should the following two uses be a compile-time error? foreach(i; 10 .. 0) // Never executes foreach(i; iota(10, 0)) // .. neither does this I

Re: foreach/iota countdown

2014-02-17 Thread simendsjo
On Monday, 17 February 2014 at 20:03:32 UTC, Timon Gehr wrote: On 02/17/2014 08:33 PM, simendsjo wrote: On Monday, 17 February 2014 at 19:30:38 UTC, Timon Gehr wrote: On 02/17/2014 08:22 PM, simendsjo wrote: Should the following two uses be a compile-time error? foreach(i; 10 .. 0) // Never

Re: foreach/iota countdown

2014-02-17 Thread Timon Gehr
On 02/17/2014 09:21 PM, simendsjo wrote: On Monday, 17 February 2014 at 20:03:32 UTC, Timon Gehr wrote: ... It was just to illustrate the issue more clearly. Eg. it means one and the same iota expression can sometimes iterate in one direction and in the other direction at other times. That's

Re: foreach/iota countdown

2014-02-17 Thread simendsjo
On Monday, 17 February 2014 at 21:06:50 UTC, Timon Gehr wrote: On 02/17/2014 09:21 PM, simendsjo wrote: On Monday, 17 February 2014 at 20:03:32 UTC, Timon Gehr wrote: ... It was just to illustrate the issue more clearly. Eg. it means one and the same iota expression can sometimes iterate in

Re: foreach/iota countdown

2014-02-17 Thread Timon Gehr
On 02/17/2014 10:12 PM, simendsjo wrote: Ok, I yield. I just happened to write foreach(i; 10 .. 0) and was suprised that it didn't give any warnings or errors. But I still somewhat stand by my point: Dead code is illegal in D, (No it is not. Some forms of dead code are detected by DMD,

Re: Optimize my code =)

2014-02-17 Thread Robin
Hiho, thank you for your code improvements and suggestions. I really like the foreach loop in D as well as the slight (but existing) performance boost over conventional for loops. =) Another success of the changes I have made is that I have achieved to further improve the matrix

Re: Optimize my code =)

2014-02-17 Thread bearophile
Robin: The key to victory was pointer arithmetics as I notices that I have used them in the C++ implementation, too. xD Perhaps with LDC2 it's not necessary. I will just post the whole code again so that you can see what I have changed. The code looks better. There's no need to put

Re: Optimize my code =)

2014-02-17 Thread Nick Sabalausky
On 2/16/2014 6:47 PM, Robin wrote: @Nick Sabalausky: Don't be shocked at the bad performance of a beginner D programmer. At least I am not shocked yet that my D implementation isn't performing as well as the highly optimized C++11 implementation or the JIT-optimized Java implementation. In

Re: Optimize my code =)

2014-02-17 Thread Nick Sabalausky
On 2/17/2014 4:56 PM, Robin wrote: And here is the complete and improved code: http://dpaste.dzfl.pl/7f8610efa82b You should get rid of the .dup's in the constructors and postblits. You don't want big arrays ever getting accidentally allocated and copied behind your back when you're only

Re: Optimize my code =)

2014-02-17 Thread Kapps
On Monday, 17 February 2014 at 11:34:43 UTC, bearophile wrote: foreach (ref T element; this.data) { element *= scalar; } Try to use: data[] *= scalar; for (auto i = 0; i this.dim.size; ++i) { this.data[i] += other.data[i]; } Try to

Re: Optimize my code =)

2014-02-17 Thread bearophile
Kapps: I remember array operations (such as data[] -= other.data[]) being significantly slower than doing it yourself. I don't know if this has been fixed. They are not being fixed. But for arrays as large as the ones here, they are fast enough. - I have tested the

Re: foreach/iota countdown

2014-02-17 Thread Francesco Cattoglio
On Monday, 17 February 2014 at 20:21:30 UTC, simendsjo wrote: I wouldn't call it randomly. In that case you should call it randomly that it suddenly doesn't run once you try to step downward. I didn't had time to work more on the iota. Perhaps after 2.065 is out I can resume working on that,

Is this meant to be possible?

2014-02-17 Thread ted
I've been using D (at a primitive level) for a while now at work (a large test-harness that exercises our main code. The harness launches and monitors multiple processes with multiple threads and performs actions on those processes to ensure correct behaviour). I am wanting to stretch my 'D'

Re: Is this meant to be possible?

2014-02-17 Thread Adam D. Ruppe
On Tuesday, 18 February 2014 at 00:31:22 UTC, ted wrote: public interface IProvider { string providedType(); T createInstance(T)(); This will cause the linker problem because templates cannot be virtual. This is declaring a final method in the interface that is never implemented.

Re: Is this meant to be possible?

2014-02-17 Thread ted
Fantastic !! (thanks !) so is: createDynamicInstance(ClassInfo type) { return type.create(); } the correct implementation ?? - it certainly seems to work... Adam D. Ruppe wrote: On Tuesday, 18 February 2014 at 00:31:22 UTC, ted wrote: public interface IProvider { string

Re: Optimize my code =)

2014-02-17 Thread Chris Williams
On Friday, 14 February 2014 at 16:00:09 UTC, Robin wrote: this(size_t rows, size_t cols) { this.dim = Dimension(rows, cols); this.data = new T[this.dim.size]; enum nil = to!T(0); foreach(ref T element; this.data) element = nil; } Your foreach here is

Question about CPU caches and D context pointers

2014-02-17 Thread Etienne
I've had his question at the back of my mind and I know it's probably related to back-end optimizations but I'm taking a chance to see if anyone knows anything. I know everything about how insignificant the speed difference may be, but keep in mind this is to further my low-level

Re: Optimize my code =)

2014-02-17 Thread Stanislav Blinov
On Tuesday, 18 February 2014 at 03:32:48 UTC, Stanislav Blinov wrote: 3) Ditch extra constructors, they're completely unnecessary. For matrix you only need your non-trivial ctor, postblit and lvalue assignment operator. Actually rvalue opAssign would be even better :) Also, I forgot to

Re: foreach/iota countdown

2014-02-17 Thread Brian Schott
On Monday, 17 February 2014 at 19:22:38 UTC, simendsjo wrote: Should the following two uses be a compile-time error? foreach(i; 10 .. 0) // Never executes foreach(i; iota(10, 0)) // .. neither does this I would like the second to either be a compile-time error or automagically use a

Re: pragma mangle hacking

2014-02-17 Thread evilrat
ok. gone making wrappers now :(

Re: [video tutorial] Implementing a simple number guessing game

2014-02-17 Thread Suliman
On Monday, 17 February 2014 at 13:35:34 UTC, simendsjo wrote: http://youtu.be/2Co65Ftxfdo Thanks! But could you use bigger fonts and more contrast color scheme for better view in next videos?

Re: [video tutorial] Implementing a simple number guessing game

2014-02-17 Thread simendsjo
On Tuesday, 18 February 2014 at 07:06:11 UTC, Suliman wrote: On Monday, 17 February 2014 at 13:35:34 UTC, simendsjo wrote: http://youtu.be/2Co65Ftxfdo Thanks! But could you use bigger fonts and more contrast color scheme for better view in next videos? I'll increase the font size, but I

Re: Optimize my code =)

2014-02-17 Thread bearophile
Stanislav Blinov: that explicit ctor for Dimension is completely unnecessary too. I like a constructor(s) like that because it catches bugs like: auto d = Dimension(5); Bye, bearophile

Re: Optimize my code =)

2014-02-17 Thread bearophile
Stanislav Blinov: http://dpaste.dzfl.pl/9d7feeab59f6 Few small things should still be improved, but it's an improvement. Perhaps it needs to use a reference counting from Phobos. LDC yields roughly the same times. This is surprising. Bye, bearophile

Re: Question about CPU caches and D context pointers

2014-02-17 Thread Tobias Pankrath
On Tuesday, 18 February 2014 at 03:15:59 UTC, Etienne wrote: I'm sorry if the question seems complicated, I read everything Ulrich Drepper had to say in What every programmer should know about memory, and I still have a bit of a hard time visualizing the question myself. I am by far no