Re: compile time regex

2012-06-16 Thread Philippe Sigaud
On Sat, Jun 16, 2012 at 10:50 PM, Dmitry Olshansky 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 that most reg

Re: align(16) struct member throws an exception with movdqa

2012-06-16 Thread Kapps
On Monday, 11 June 2012 at 03:19:08 UTC, ixid wrote: struct a { align(16) int[4] test = [1,2,3,4]; } a test; asm { movdqa XMM0, test ; addps XMM0, XMM0; movdpa test, XMM0 ; } This works fine with unaligned movdqu but thro

Re: Getting started with threads in D

2012-06-16 Thread Jonathan M Davis
On Sunday, June 17, 2012 03:15:44 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 woul

Getting started with threads in D

2012-06-16 Thread Henrik Valter Vogelius Hansson
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 be suitable for me. A little background could help. I am a game developer an

Re: sorting associative array's keys by values

2012-06-16 Thread Jonathan M Davis
On Sunday, June 17, 2012 01:35:56 maarten van damme wrote: > It should allways contain so it has more then 2 elements and > there is a note section that starts with " parsing and break out of the loop so those two should've been > statisfied. The problem was (I think) the downloader. Now I get waa

Re: sorting associative array's keys by values

2012-06-16 Thread maarten van damme
It should allways contain so it has more then 2 elements and there is a note section that starts with "

Re: sorting associative array's keys by values

2012-06-16 Thread Ali Çehreli
On 06/16/2012 03:28 PM, maarten van damme wrote: > And the output I get is It is possible that some part of the code is reusing a string buffer. For example, File.byLine does that. > tradeDocument=tradeDocument[1..$]; For that to work, you must ensure that tradeDocument has at least 2 eleme

Re: sorting associative array's keys by values

2012-06-16 Thread maarten van damme
Ah, wait a second. After playing a bit with the try catches and actually writing some proper debug output I found out the problem was with https://github.com/Bystroushaak/DHTTPClient/blob/master/dhttpclient.d. It doesn't allways download the complete webpage. I should've written better tests I gue

Re: sorting associative array's keys by values

2012-06-16 Thread Jonathan M Davis
On Sunday, June 17, 2012 00:28:07 maarten van damme wrote: > I wanted to catch it because I could not for the life of me understand > how downloading the exact same page twice could alter it's contents in > such a way that it causes the program to crash. > > There's something really strange going

Re: sorting associative array's keys by values

2012-06-16 Thread maarten van damme
I wanted to catch it because I could not for the life of me understand how downloading the exact same page twice could alter it's contents in such a way that it causes the program to crash. There's something really strange going on (or maybe I'm just too tired to see the obvious) My code literally

Re: sorting associative array's keys by values

2012-06-16 Thread Jonathan M Davis
On Saturday, June 16, 2012 21:48:52 maarten van damme wrote: > Ok, It turns out that an array out of bound exception isn't an > exception but an error? > Try catch (Error e) worked fine. Yes, it's a RangeError. It's considered a programming bug if you access an array out of bounds - just like any

Re: sorting associative array's keys by values

2012-06-16 Thread maarten van damme
Nothing unsafe. I use https://github.com/Bystroushaak/DHTTPClient to download a webpage and other then that I only use slicing...

Re: compile time regex

2012-06-16 Thread Dmitry Olshansky
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 that most regexes actually _compile_ at CTFE. -- Dmitry Olshansky

compile time regex

2012-06-16 Thread Ellery Newcomer
There is a ctRegex; is there a compile time equivalent for match?

Re: Implicit conversion from class in parent class fails?

2012-06-16 Thread Ali Çehreli
On 06/16/2012 11:55 AM, Andrew Wiley wrote: On Sat, Jun 16, 2012 at 11:52 AM, Namespace wrote: Why work this: [code] class Foo { } class Bar : Foo { } class Quatz : Bar { } void foo(Foo f) { } void main() { Foo f = new Foo(); Foo f2; foo(f); foo(f2);

Re: sorting associative array's keys by values

2012-06-16 Thread Timon Gehr
On 06/16/2012 07:51 PM, maarten van damme wrote: For some crazy reason my program now crashes on seemingly random locations when parsing content of the form: randomname I want to extract randomname but an xml parser would be overkill so I extract it using curLine=curLine[curLine.

Re: sorting associative array's keys by values

2012-06-16 Thread maarten van damme
Ok, It turns out that an array out of bound exception isn't an exception but an error? Try catch (Error e) worked fine.

Re: Implicit conversion from class in parent class fails?

2012-06-16 Thread Andrew Wiley
On Sat, Jun 16, 2012 at 11:52 AM, Namespace wrote: > Why work this: > > [code] > class Foo { } > class Bar : Foo { } > class Quatz : Bar { } > > void foo(Foo f) { > > } > > void main() { >        Foo f = new Foo(); >        Foo f2; > >        foo(f); >        foo(f2); > >        Bar b = new Bar();

Implicit conversion from class in parent class fails?

2012-06-16 Thread Namespace
Why work this: [code] class Foo { } class Bar : Foo { } class Quatz : Bar { } void foo(Foo f) { } void main() { Foo f = new Foo(); Foo f2; foo(f); foo(f2); Bar b = new Bar(); Bar b2; foo(b); foo(b2);

Re: sorting associative array's keys by values

2012-06-16 Thread maarten van damme
For some crazy reason my program now crashes on seemingly random locations when parsing content of the form: randomname I want to extract randomname but an xml parser would be overkill so I extract it using curLine=curLine[curLine.countUntil(">")

Re: sorting associative array's keys by values

2012-06-16 Thread maarten van damme
thank you, works perfectly. I'm really having some troubles understanding the whole std.algorithm documentation although it is a module I've had to use in nearly every single program I wrote and it's always extremely powerful.

Re: sorting associative array's keys by values

2012-06-16 Thread Timon Gehr
On 06/16/2012 06:41 PM, Timon Gehr wrote: On 06/16/2012 06:34 PM, maarten van damme wrote: Right now I have an associative array "int[string] aa" and stored the keys in "string[] keys". Now I want to sort keys[] so that "aa[keys[0]]>aa[keys[1]]" I remember someone gave the answer to that questio

Re: sorting associative array's keys by values

2012-06-16 Thread Timon Gehr
On 06/16/2012 06:34 PM, maarten van damme wrote: Right now I have an associative array "int[string] aa" and stored the keys in "string[] keys". Now I want to sort keys[] so that "aa[keys[0]]>aa[keys[1]]" I remember someone gave the answer to that question on stackoverflow but after some googling

sorting associative array's keys by values

2012-06-16 Thread maarten van damme
Right now I have an associative array "int[string] aa" and stored the keys in "string[] keys". Now I want to sort keys[] so that "aa[keys[0]]>aa[keys[1]]" I remember someone gave the answer to that question on stackoverflow but after some googling I couldn't find the right answer. maarten

Re: Using consistently auto as function return type

2012-06-16 Thread bearophile
Tommi: Do you consider it to be good or bad style of programming to use consistently auto as function return type? In Python programming you don't specify the types of function arguments and return values, but while this is possible in Haskell too, it's good practice to write down input and

Re: Using consistently auto as function return type

2012-06-16 Thread Timon Gehr
On 06/16/2012 11:31 AM, Tommi wrote: Do you consider it to be good or bad style of programming to use consistently auto as function return type? One of the pros is that it saves some redundant typing when the function returns some complex templated type: auto getValue() { return MyType!(in

Re: Using consistently auto as function return type

2012-06-16 Thread Era Scarecrow
On Saturday, 16 June 2012 at 09:31:35 UTC, Tommi wrote: Do you consider it to be good or bad style of programming to use consistently auto as function return type? One of the pros is that it saves some redundant typing when the function returns some complex templated type: auto getValue() {

Using consistently auto as function return type

2012-06-16 Thread Tommi
Do you consider it to be good or bad style of programming to use consistently auto as function return type? One of the pros is that it saves some redundant typing when the function returns some complex templated type: auto getValue() { return MyType!(int, "asdf", 64).init; } But one of t

Re: dirEntries fails with option -inline

2012-06-16 Thread Jonathan M Davis
On Saturday, June 16, 2012 09:41:44 cal wrote: > This code: > > auto dFiles = dirEntries("testimages/","*.png",SpanMode.shallow); > foreach(d; dFiles) >writeln(d.name); > > fails to generate a directory listing when I compile with -inline > option to DMD v2.058. It works fine otherwise, both

dirEntries fails with option -inline

2012-06-16 Thread cal
This code: auto dFiles = dirEntries("testimages/","*.png",SpanMode.shallow); foreach(d; dFiles) writeln(d.name); fails to generate a directory listing when I compile with -inline option to DMD v2.058. It works fine otherwise, both release and debug, with or without -O etc. Is this a bug,