Re: compile time regex

2012-06-17 Thread Philippe Sigaud
On Sat, Jun 16, 2012 at 10:50 PM, Dmitry Olshansky dmitry.o...@gmail.com wrote: On 17.06.2012 0:44, Ellery Newcomer wrote: There is a ctRegex; is there a compile time equivalent for match? No. Since last time I tried to hack through CTFE it failed horribly. Bleh, I'd rather first make sure

Re: Getting started with threads in D

2012-06-17 Thread Russel Winder
On Sun, 2012-06-17 at 03:15 +0200, Henrik Valter Vogelius Hansson wrote: Hi again! I have looked around a little with what D offers but don't know really what I should use since D offers several ways to use threads. Some more high level than others. Don't really also know which one would

readText fails to open file

2012-06-17 Thread GreatEmerald
This is kind of silly, and I probably missed something, but for some reason I can't get any kind of text file opened when using readText from std.file. This is what I'm trying to do: import std.stdio; import std.file; int main(string[] args) { if (!isFile(args[0])) {

Re: readText fails to open file

2012-06-17 Thread Dmitry Olshansky
On 17.06.2012 12:21, GreatEmerald wrote: This is kind of silly, and I probably missed something, but for some reason I can't get any kind of text file opened when using readText from std.file. This is what I'm trying to do: import std.stdio; import std.file; int main(string[] args) { if

Re: readText fails to open file

2012-06-17 Thread Ali Çehreli
On 06/17/2012 01:21 AM, GreatEmerald wrote: This is kind of silly, and I probably missed something, but for some reason I can't get any kind of text file opened when using readText from std.file. This is what I'm trying to do: import std.stdio; import std.file; int main(string[] args) { if

Re: readText fails to open file

2012-06-17 Thread Jonathan M Davis
On Sunday, June 17, 2012 10:21:17 GreatEmerald wrote: This is kind of silly, and I probably missed something, but for some reason I can't get any kind of text file opened when using readText from std.file. This is what I'm trying to do: import std.stdio; import std.file; int

Re: readText fails to open file

2012-06-17 Thread GreatEmerald
Oh, I just figured out what was going wrong. Apparently, args[0] is the path to the program itself, and not the first argument. args[1] is what I need to start reading from!

Re: sorting associative array's keys by values

2012-06-17 Thread maarten van damme
well, the page I parse is automatically generated and thus allways contains /html. (if the page completely downloaded which it didn't). The second error I found (my mistake) is that newlines get scrambled up severely when downloading the page causing the markers I try to find to sometimes break

Re: sorting associative array's keys by values

2012-06-17 Thread Jonathan M Davis
On Sunday, June 17, 2012 13:07:24 maarten van damme wrote: well, the page I parse is automatically generated and thus allways contains /html. That may be true, but if your code assumes that /html is there and it ever isn't for any reason, then you're going to get a RangeError thrown in non-

Re: readText fails to open file

2012-06-17 Thread GreatEmerald
On Sunday, 17 June 2012 at 08:35:58 UTC, Jonathan M Davis wrote: Also, you need to check exists before you check isFile, otherwise isFile will blow up if the file doesn't exst. And both of those are properties, so you should be calling them like auto filename = args[1]; if(!filename.exists

Casting the Result of splitter() into a string array

2012-06-17 Thread GreatEmerald
A quick and simple question, but I couldn't find the answer to it by myself: how do I cast the return type of std.array.splitter() into a string[]? According to the compiler, splitter() has a return type Result. How useful... I assume it's a disguised tuple? If I try to simply assign the

COM-Interfaces

2012-06-17 Thread Denis Shelomovskij
Here http://dlang.org/interface.html#COM-Interfaces we have a link to Lionello Lunesu's article http://lunesu.com/uploads/ModernCOMProgramminginD.pdf Is it correct that he hasn't managed to convince Microsoft to release his sources and one of us has to rewrite his library if we want to use it?

Re: Casting the Result of splitter() into a string array

2012-06-17 Thread Jonathan M Davis
On Sunday, June 17, 2012 13:39:19 GreatEmerald wrote: A quick and simple question, but I couldn't find the answer to it by myself: how do I cast the return type of std.array.splitter() into a string[]? According to the compiler, splitter() has a return type Result. How useful... I assume

Re: Casting the Result of splitter() into a string array

2012-06-17 Thread GreatEmerald
On Sunday, 17 June 2012 at 11:58:58 UTC, Jonathan M Davis wrote: splitter( a b ) is going to return a range of strings. If you were to do array(splitter(a b )), you'd get [, a, b]. Aha, that worked! Thanks! Still makes me wonder how you're supposed to figure out that this type is a range

Re: Casting the Result of splitter() into a string array

2012-06-17 Thread bearophile
GreatEmerald: A quick and simple question, but I couldn't find the answer to it by myself: how do I cast the return type of std.array.splitter() into a string[]? splitter(), filter(), etc, are lazy, they return an iterable. Use split() instead of splitter(). Bye, bearophile

Re: Casting the Result of splitter() into a string array

2012-06-17 Thread Jonathan M Davis
On Sunday, June 17, 2012 14:11:27 GreatEmerald wrote: On Sunday, 17 June 2012 at 11:58:58 UTC, Jonathan M Davis wrote: splitter( a b ) is going to return a range of strings. If you were to do array(splitter(a b )), you'd get [, a, b]. Aha, that worked! Thanks! Still makes me wonder

Re: sorting associative array's keys by values

2012-06-17 Thread maarten van damme
Ok, everything worked (nearly perfect). Sometimes the webpage gets completely messed up ( changes to d134 or something like that) but the tests handle it rather well. That's why I decided to improve it a bit and use treads. I've always been afraid of d treads because I never really got the grasp

Re: Casting the Result of splitter() into a string array

2012-06-17 Thread Trass3r
If you want to convert a range to an array, use std.array.array This is a constant source of confusion and it also is a crappy design to use a function in a totally different module for this purpose imho. Can't these Result types get an eval() method and/or be made implicitly convertible to

Re: sorting associative array's keys by values

2012-06-17 Thread maarten van damme
another problem, when I do use shared. My code is int amountTreads = 20; if(upperLimit-lowerLimitamountTreads) amountTreads=upperLimit-lowerLimit; int perTrade = (upperLimit - lowerLimit) / amountTreads; for (int x = 0; x amountTreads; x++) {

Re: Writing .di files

2012-06-17 Thread David
Am 17.06.2012 16:04, schrieb Minas: Is there a good tutorial about how to write .di files? You don't write them, the compiler outputs them with the -H option.

Re: Writing .di files

2012-06-17 Thread Jordi Sayol
Al 17/06/12 16:04, En/na Minas ha escrit: Is there a good tutorial about how to write .di files? http://dlang.org/dmd-linux.html#interface_files -- Jordi Sayol

Simulating rectangular array

2012-06-17 Thread Andrej Mitrovic
Has anyone come up with a template that can simulate a rectangular array and allow one to override opAssign to do special work? E.g.: Array!(2, 4) arr; arr[1][3] = foo; This would invoke opAssign in some templated struct Array. This would be super-easy to implement if I had an opIndex that could

Re: Simulating rectangular array

2012-06-17 Thread Jonathan M Davis
On Sunday, June 17, 2012 21:50:32 Andrej Mitrovic wrote: Has anyone come up with a template that can simulate a rectangular array and allow one to override opAssign to do special work? E.g.: Array!(2, 4) arr; arr[1][3] = foo; This would invoke opAssign in some templated struct Array. This

Re: Simulating rectangular array

2012-06-17 Thread Philippe Sigaud
On Sun, Jun 17, 2012 at 9:50 PM, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Has anyone come up with a template that can simulate a rectangular array and allow one to override opAssign to do special work? E.g.: Array!(2, 4) arr; arr[1][3] = foo; This would invoke opAssign in some

Re: COM-Interfaces

2012-06-17 Thread Jesse Phillips
On Sunday, 17 June 2012 at 11:57:36 UTC, Denis Shelomovskij wrote: Here http://dlang.org/interface.html#COM-Interfaces we have a link to Lionello Lunesu's article http://lunesu.com/uploads/ModernCOMProgramminginD.pdf Is it correct that he hasn't managed to convince Microsoft to release his