Re: Is this a good pattern for allocation?

2013-08-05 Thread Tobias Pankrath
On Monday, 5 August 2013 at 01:47:26 UTC, JS wrote: Anyways, is this a bad or good way and how can I call Factory to get a new object? (I know that ther is .init and other stuff that can be used by Factor/New. I'm just trying to get the skeleton to compile and make sure there are not going to b

Re: Is this a good pattern for allocation?

2013-08-05 Thread JS
On Monday, 5 August 2013 at 07:15:30 UTC, Tobias Pankrath wrote: On Monday, 5 August 2013 at 01:47:26 UTC, JS wrote: Anyways, is this a bad or good way and how can I call Factory to get a new object? (I know that ther is .init and other stuff that can be used by Factor/New. I'm just trying to g

Re: What would be the best way to compile a project with GDC?

2013-08-05 Thread Joseph Rushton Wakeling
On 08/01/2013 07:46 PM, Gary Willoughby wrote: > There must be a simpler way to pass these files to dmd in the right order? > rdmd > does it somehow. > > Any ideas? How do you handle compiling projects with 50+ source files? This is a Makefile pattern I've found useful: https://github.com/WebDra

get user config dir

2013-08-05 Thread Nick Treleaven
Hi, Does Phobos have a way to portably get the user's configuration directory? As an example, GTK+ has this: http://www.gtk.org/api/2.6/glib/glib-Miscellaneous-Utility-Functions.html#g-get-user-config-dir Thanks, Nick

Re: get user config dir

2013-08-05 Thread Mike Parker
On Monday, 5 August 2013 at 11:43:05 UTC, Nick Treleaven wrote: Hi, Does Phobos have a way to portably get the user's configuration directory? As an example, GTK+ has this: http://www.gtk.org/api/2.6/glib/glib-Miscellaneous-Utility-Functions.html#g-get-user-config-dir No, it doesn't. I use P

Re: Is this a good pattern for allocation?

2013-08-05 Thread Tobias Pankrath
On Monday, 5 August 2013 at 08:11:59 UTC, JS wrote: I guess you mean that I should use a template as a factory instead of an interface? I'll have to think about it to see what the pro's and con's of each are. The interface pattern should include the template pattern though. (after all, the in

Matter of style, and cast()

2013-08-05 Thread bearophile
Some small style rules for D user code: 1) All variables and functions arguments should be immutable/const (or enum), unless they have to mutate (or there is some other problem in Phobos, in the D type system, or in your other code). 2) The code should contain as few cast() as possible. [*]

Re: Matter of style, and cast()

2013-08-05 Thread Joseph Rushton Wakeling
On 08/05/2013 03:01 PM, bearophile wrote: > 2) The code should contain as few cast() as possible. [*] What about to!() ... ? Is it possible to gain the performance of cast() while using to!() ... ? > 4) for/foreach/while loops are not evil, but it's better to use map/filter/zip > where possible

Which option is faster...

2013-08-05 Thread jicman
Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.string.tolower(fext[0]) == "ppt" || std.string.tolower(fe

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, First option... foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xl

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 14:13:33 UTC, Timon Gehr wrote: On 08/05/2013 03:59 PM, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string

Re: Which option is faster...

2013-08-05 Thread Timon Gehr
On 08/05/2013 03:59 PM, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.string.tolower(fe

Re: Which option is faster...

2013-08-05 Thread dennis luehring
did you benchmarked your current szenario - how do you know that this is the slow part - or are you working on an only-extension-compare-tool? btw: they are both equal and slow - and full of partly code-duplication std.string.tolower(fext[0]) multiple times, i hope your list isn't going much lo

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 14:27:43 UTC, dennis luehring wrote: did you benchmarked your current szenario - how do you know that this is the slow part - or are you working on an only-extension-compare-tool? btw: they are both equal and slow - and full of partly code-duplication std.string.to

Re: Which option is faster...

2013-08-05 Thread H. S. Teoh
On Mon, Aug 05, 2013 at 03:59:23PM +0200, jicman wrote: > > Greetings! > > I have this code, > > foreach (...) > { > > if (std.string.tolower(fext[0]) == "doc" || > std.string.tolower(fext[0]) == "docx" || > std.string.tolower(fext[0]) == "xls" || > std.string.tolower(fext[0]) ==

Re: Matter of style, and cast()

2013-08-05 Thread Bosak
On Monday, 5 August 2013 at 13:01:19 UTC, bearophile wrote: Some small style rules for D user code: 1) All variables and functions arguments should be immutable/const (or enum), unless they have to mutate (or there is some other problem in Phobos, in the D type system, or in your other code).

Re: Which option is faster...

2013-08-05 Thread dennis luehring
> Ok, how would you make it faster? i don't see a better solution here - how to reduce ONE lowercase and SOME compares in any way? (i dont think a hash or something will help) but i know that anything like your continue-party is worth nothing (feels a little bit like script-kiddies "do it with

Re: Which option is faster...

2013-08-05 Thread bearophile
jicman: How would you make it faster in D1? Compute std.string.tolower(fext[0]) and put it in a temporary variable. And then compare that variable with all your string literals. In most cases that's fast enough. If it's not enough, you could create a little finite state machine that represe

Re: Is this a good pattern for allocation?

2013-08-05 Thread JS
On Monday, 5 August 2013 at 12:41:19 UTC, Tobias Pankrath wrote: On Monday, 5 August 2013 at 08:11:59 UTC, JS wrote: I guess you mean that I should use a template as a factory instead of an interface? I'll have to think about it to see what the pro's and con's of each are. The interface patter

Re: Matter of style, and cast()

2013-08-05 Thread Bosak
I made a markdown gist for the above module import tips: https://gist.github.com/nikibobi/6156492

Re: Which option is faster...

2013-08-05 Thread John Colvin
On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.stri

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 14:47:37 UTC, dennis luehring wrote: > Ok, how would you make it faster? i don't see a better solution here - how to reduce ONE lowercase and SOME compares in any way? (i dont think a hash or something will help) but i know that anything like your continue-party is

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 14:50:27 UTC, bearophile wrote: jicman: How would you make it faster in D1? Compute std.string.tolower(fext[0]) and put it in a temporary variable. And then compare that variable with all your string literals. In most cases that's fast enough. If it's not enough,

Re: get user config dir

2013-08-05 Thread Nick Treleaven
On 05/08/2013 13:24, Mike Parker wrote: On Monday, 5 August 2013 at 11:43:05 UTC, Nick Treleaven wrote: Hi, Does Phobos have a way to portably get the user's configuration directory? As an example, GTK+ has this: http://www.gtk.org/api/2.6/glib/glib-Miscellaneous-Utility-Functions.html#g-get-us

Re: Which option is faster...

2013-08-05 Thread David
Am 05.08.2013 15:59, schrieb jicman: > > Greetings! > > I have this code, > > foreach (...) > { > > if (std.string.tolower(fext[0]) == "doc" || > std.string.tolower(fext[0]) == "docx" || > std.string.tolower(fext[0]) == "xls" || > std.string.tolower(fext[0]) == "xlsx" || > std

Re: Matter of style, and cast()

2013-08-05 Thread H. S. Teoh
On Mon, Aug 05, 2013 at 03:01:18PM +0200, bearophile wrote: > Some small style rules for D user code: [...] Note that in git HEAD, importing of packages as modules has been implemented via package.d: import my.path.module; will now also work with: /my /my/path /m

Re: Which option is faster...

2013-08-05 Thread dennis luehring
Am 05.08.2013 17:18, schrieb jicman: > It is a tool that was a script, but I have turned it into do, which now has taken two hours from the last jscript script. I have not benchmarked it, yet. I may. But I see that a great idea has been provided, which I will use. Thanks for the help. > hav

Re: Which option is faster...

2013-08-05 Thread H. S. Teoh
On Mon, Aug 05, 2013 at 04:47:36PM +0200, dennis luehring wrote: > > Ok, how would you make it faster? > > i don't see a better solution here - how to reduce ONE lowercase and > SOME compares in any way? (i dont think a hash or something will > help) but i know that anything like your continue-par

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 15:18:42 UTC, John Colvin wrote: On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" |

Re: Which option is faster...

2013-08-05 Thread John Colvin
On Monday, 5 August 2013 at 15:21:25 UTC, David wrote: Am 05.08.2013 15:59, schrieb jicman: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolow

Re: Which option is faster...

2013-08-05 Thread monarch_dodra
On Monday, 5 August 2013 at 15:18:42 UTC, John Colvin wrote: better: foreach (...) { auto tmp = std.string.tolower(fext[0]); if(tmp == "doc" || tmp == "docx" || tmp == "xls" || tmp == "xlsx" || tmp == "ppt" || tmp == "pptx") { continue; } } but still not s

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 15:27:09 UTC, dennis luehring wrote: Am 05.08.2013 17:18, schrieb jicman: > It is a tool that was a script, but I have turned it into do, which now has taken two hours from the last jscript script. I have not benchmarked it, yet. I may. But I see that a great idea

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 17:04:36 UTC, monarch_dodra wrote: On Monday, 5 August 2013 at 15:18:42 UTC, John Colvin wrote: better: foreach (...) { auto tmp = std.string.tolower(fext[0]); if(tmp == "doc" || tmp == "docx" || tmp == "xls" || tmp == "xlsx" || tmp == "ppt" || tmp

Re: Which option is faster...

2013-08-05 Thread Ali Çehreli
On 08/05/2013 10:04 AM, jicman wrote: > The files are in a network drive, so, that has some slowness already > involved because of that. Which may dominate the running time. > The jscript use to take over 8 hours. The new D program has > dropped that to under less than six. And that is proof

Re: Which option is faster...

2013-08-05 Thread JS
On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.stri

Re: Which option is faster...

2013-08-05 Thread H. S. Teoh
On Mon, Aug 05, 2013 at 07:30:36PM +0200, JS wrote: > On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: > > > >Greetings! > > > >I have this code, > > > >foreach (...) > >{ > > > > if (std.string.tolower(fext[0]) == "doc" || > >std.string.tolower(fext[0]) == "docx" || > >std.string.t

tuple parameter fwd

2013-08-05 Thread kdmult
Hi, I would like to use a tuple template parameter in the default value of another template parameter in the same class declaration as follows. class A(P...) {} class B(R = A!P, P...) {} P... should be rightmost, so how can I use it in the preceding parameter? Thanks.

Re: Matter of style, and cast()

2013-08-05 Thread Jonathan M Davis
On Monday, August 05, 2013 15:46:13 Joseph Rushton Wakeling wrote: > On 08/05/2013 03:01 PM, bearophile wrote: > > 2) The code should contain as few cast() as possible. [*] > > What about to!() ... ? Is it possible to gain the performance of cast() > while using to!() ... ? That depends. In gener

Re: Started to work on a Lua wrapper. Please provide feedback & guidance

2013-08-05 Thread Jesse Phillips
On Saturday, 3 August 2013 at 22:17:32 UTC, Gabi wrote: I need a Lua 5.2.2 wrapper, So I started working on one.. I am new to D so probably there is a lot of room for improvements.. Any feedback is welcome.. You'll probably like the LuaD wrapper https://github.com/JakobOvrum/LuaD It uses 5.

Re: tuple parameter fwd

2013-08-05 Thread Artur Skawina
On 08/05/13 20:45, kdmult wrote: > Hi, > > I would like to use a tuple template parameter in the default value of > another template parameter in the same class declaration as follows. > > class A(P...) {} > > class B(R = A!P, P...) {} > > P... should be rightmost, so how can I use it in the p

Re: Started to work on a Lua wrapper. Please provide feedback & guidance

2013-08-05 Thread Gabi
On Monday, 5 August 2013 at 19:14:25 UTC, Jesse Phillips wrote: On Saturday, 3 August 2013 at 22:17:32 UTC, Gabi wrote: I need a Lua 5.2.2 wrapper, So I started working on one.. I am new to D so probably there is a lot of room for improvements.. Any feedback is welcome.. You'll probably like

Getting number of messages in MessageBox

2013-08-05 Thread Marek Janukowicz
I'm using std.concurrency message passing and I'd like to check which thread might be a bottleneck. The easiest would be check number of messages piled up for each of them, but I could not find a way to do that. Is it possible? Every detail about MessageBox seems to be hidden... -- Marek Januk

Re: Getting number of messages in MessageBox

2013-08-05 Thread Andrej Mitrovic
On 8/6/13, Marek Janukowicz wrote: > I'm using std.concurrency message passing and I'd like to check which thread > might be a bottleneck. The easiest would be check number of messages piled > up for each of them, but I could not find a way to do that. Is it possible? > > Every detail about Messag

Re: Which option is faster...

2013-08-05 Thread Raphaël Jakse
Le 05/08/2013 15:59, jicman a écrit : Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.string.tolower(fe

Re: Getting number of messages in MessageBox

2013-08-05 Thread Ali Çehreli
On 08/05/2013 04:18 PM, Marek Janukowicz wrote: I'm using std.concurrency message passing and I'd like to check which thread might be a bottleneck. The easiest would be check number of messages piled up for each of them, but I could not find a way to do that. Is it possible? Every detail about Me

Re: Which option is faster...

2013-08-05 Thread Andre Artus
On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.stri

Logging and tracing in D

2013-08-05 Thread Andre Artus
What is the recommended approach for adding logging and tracing to D apps? Is there a library for it?

Re: Reading a structured binary file?

2013-08-05 Thread Jesse Phillips
On Saturday, 3 August 2013 at 18:23:58 UTC, Gary Willoughby wrote: On Saturday, 3 August 2013 at 18:14:47 UTC, Gary Willoughby wrote: This sounds a great idea but once the file has been opened as a MmFile how to i convert this to a ubyte[] so the std.bitmanip functions work with it? I'm curre

Re: tuple parameter fwd

2013-08-05 Thread kdmult
On Monday, 5 August 2013 at 18:45:49 UTC, kdmult wrote: class A(P...) {} class B(R = A!P, P...) {} P... should be rightmost, so how can I use it in the preceding parameter? The default parameter value doesn't make sense as it's shown above. Actually I want to port C++ code which looks like

Re: tuple parameter fwd

2013-08-05 Thread Ali Çehreli
On 08/05/2013 09:51 PM, kdmult wrote: On Monday, 5 August 2013 at 18:45:49 UTC, kdmult wrote: class A(P...) {} class B(R = A!P, P...) {} P... should be rightmost, so how can I use it in the preceding parameter? The default parameter value doesn't make sense as it's shown above. Actually I wa

Re: Reading a structured binary file?

2013-08-05 Thread H. S. Teoh
On Tue, Aug 06, 2013 at 06:48:12AM +0200, Jesse Phillips wrote: [...] > The only way I'm seeing to advance through the file is to keep an > index on where you're currently reading from. This actually works > perfect for the FileRange I mentioned in the previous post. Though > I'm not familiar with

Re: Getting number of messages in MessageBox

2013-08-05 Thread Marek Janukowicz
Ali Çehreli wrote: > On 08/05/2013 04:18 PM, Marek Janukowicz wrote: >> I'm using std.concurrency message passing and I'd like to check which >> thread might be a bottleneck. The easiest would be check number of >> messages piled up for each of them, but I could not find a way to do >> that. Is it

Re: Reading a structured binary file?

2013-08-05 Thread Jonathan M Davis
On Monday, August 05, 2013 23:04:58 H. S. Teoh wrote: > On Tue, Aug 06, 2013 at 06:48:12AM +0200, Jesse Phillips wrote: > [...] > > > The only way I'm seeing to advance through the file is to keep an > > index on where you're currently reading from. This actually works > > perfect for the FileRang

Re: Which option is faster...

2013-08-05 Thread dennis luehring
Am 05.08.2013 19:04, schrieb jicman: so its totaly unclear if the presented code is your 2h monster, what was the runtime of your jscript? The files are in a network drive, so, that has some slowness already involved because of that. The jscript use to take over 8 hours. The new D program has

Re: tuple parameter fwd

2013-08-05 Thread kdmult
On Tuesday, 6 August 2013 at 05:07:51 UTC, Ali Çehreli wrote: On 08/05/2013 09:51 PM, kdmult wrote: On Monday, 5 August 2013 at 18:45:49 UTC, kdmult wrote: class A(P...) {} class B(R = A!P, P...) {} P... should be rightmost, so how can I use it in the preceding parameter? The default param

Re: Which option is faster...

2013-08-05 Thread Jonathan M Davis
On Monday, August 05, 2013 15:59:23 jicman wrote: > Greetings! > > I have this code, > > foreach (...) > { > >if (std.string.tolower(fext[0]) == "doc" || > std.string.tolower(fext[0]) == "docx" || > std.string.tolower(fext[0]) == "xls" || > std.string.tolower(fext[0]) == "xlsx