Re: XML Parsing

2012-03-19 Thread Adam D. Ruppe
I know very little about std.xml (I looked at it and said 'meh' and wrote my own lib), but my lib makes this pretty simple. https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff grab dom.d and characterencodings.d This has a bit of an html bias, but it works for xm

XML Parsing

2012-03-19 Thread Chris Pons
Hey Guys, I am trying to parse an XML document with std.xml. I've looked over the reference of std.xml as well as the example but i'm still stuck. I've also looked over some example code, but it's a bit confusing and doesn't entirely help explain what i'm doing wrong. As far as I understand

Re: regex issue

2012-03-19 Thread Jay Norwood
On Monday, 19 March 2012 at 19:24:30 UTC, Jay Norwood wrote: This fails to build, so I'd guess is missing \p void wcp (string fn) { enum ctr = ctRegex!("\p{WhiteSpace}","m"); } -- Build started: Project: a7, Configuration: Release Win32 -- Building Release\a7.exe... a7.d(210):

Re: HelloWordl in Webserver

2012-03-19 Thread simendsjo
On Sun, 18 Mar 2012 06:19:47 +0100, Kapps wrote: On Saturday, 17 March 2012 at 20:52:33 UTC, Xan wrote: So, there is not built-in functions? Thanks, Xan. There's no built in webserver class, and it's not something that should be in the standard library in the first place. I think phobo

Re: HelloWordl in Webserver

2012-03-19 Thread Xan
On Sunday, 18 March 2012 at 05:19:48 UTC, Kapps wrote: On Saturday, 17 March 2012 at 20:52:33 UTC, Xan wrote: So, there is not built-in functions? Thanks, Xan. There's no built in webserver class, and it's not something that should be in the standard library in the first place. A pain. A

Re: regex issue

2012-03-19 Thread Jay Norwood
On Monday, 19 March 2012 at 13:55:39 UTC, Dmitry Olshansky wrote: That's right, however counting is completely separate from regex, you'd want to use std.algorithm count: count(match(,"\n")); or more unicode-friendly: count(match(, regex("$","m")); //note the multi-line flag This only

Re: Comparison issue

2012-03-19 Thread H. S. Teoh
On Mon, Mar 19, 2012 at 08:50:02AM -0400, bearophile wrote: > James Miller: > > > writeln(v1 == 1); //false > > writeln(v1 == 1.0); //false > > writeln(v1 == 1.0f); //false > > writeln(v1+1 == 2.0f); //true Using == to compare floating point values is wrong. Due to

Re: Comparison issue

2012-03-19 Thread Jesse Phillips
On Monday, 19 March 2012 at 12:50:02 UTC, bearophile wrote: James Miller: writeln(v1 == 1); //false writeln(v1 == 1.0); //false writeln(v1 == 1.0f); //false writeln(v1+1 == 2.0f); //true Maybe I'd like to deprecate and then statically forbid the use of == amon

Re: Comparison issue

2012-03-19 Thread James Miller
On Mar 20, 2012 1:50 AM, "bearophile" wrote: > > James Miller: > > > writeln(v1 == 1); //false > > writeln(v1 == 1.0); //false > > writeln(v1 == 1.0f); //false > > writeln(v1+1 == 2.0f); //true > > Maybe I'd like to deprecate and then statically forbid the use of ==

Re: regex issue

2012-03-19 Thread Dmitry Olshansky
On 19.03.2012 17:39, Jay Norwood wrote: On Monday, 19 March 2012 at 13:27:03 UTC, Jay Norwood wrote: ok, global. So the document implies that I should be able to get a single match object with a count of the submatches. So I think maybe I've jumped to the wrong conclusion about how to use it, th

Re: regex issue

2012-03-19 Thread Dmitry Olshansky
On 19.03.2012 17:27, Jay Norwood wrote: On Monday, 19 March 2012 at 08:05:18 UTC, Dmitry Olshansky wrote: Like I told in main D group it's wrong - regex doesn't only count matches. It finds slices that do match. Thus to make it more efficient, it returns lazy range that does searches on request.

Re: regex issue

2012-03-19 Thread Jay Norwood
On Monday, 19 March 2012 at 13:27:03 UTC, Jay Norwood wrote: ok, global. So the document implies that I should be able to get a single match object with a count of the submatches. So I think maybe I've jumped to the wrong conclusion about how to use it, thinking I could just use "\n" and "g"

Re: regex issue

2012-03-19 Thread Jay Norwood
On Monday, 19 March 2012 at 08:05:18 UTC, Dmitry Olshansky wrote: Like I told in main D group it's wrong - regex doesn't only count matches. It finds slices that do match. Thus to make it more efficient, it returns lazy range that does searches on request. "g" - means global :) Then code like t

Re: regex issue

2012-03-19 Thread Dmitry Olshansky
On 19.03.2012 16:59, Jay Norwood wrote: On Monday, 19 March 2012 at 08:14:18 UTC, Dmitry Olshansky wrote: On 19.03.2012 12:05, Dmitry Olshansky wrote: In that case, I should have been able to do something like: matches=match(input,ctr); l_cnt = matches.length(); I'm curious what this lengt

Re: regex issue

2012-03-19 Thread Jay Norwood
On Monday, 19 March 2012 at 08:14:18 UTC, Dmitry Olshansky wrote: On 19.03.2012 12:05, Dmitry Olshansky wrote: In that case, I should have been able to do something like: matches=match(input,ctr); l_cnt = matches.length(); I'm curious what this length() does as I have no length for RegexMa

Re: Comparison issue

2012-03-19 Thread bearophile
James Miller: > writeln(v1 == 1); //false > writeln(v1 == 1.0); //false > writeln(v1 == 1.0f); //false > writeln(v1+1 == 2.0f); //true Maybe I'd like to deprecate and then statically forbid the use of == among floating point values, and replace it with a library-d

Re: Problem about Tuple.opEquals, const qualifier

2012-03-19 Thread Steven Schveighoffer
On Sat, 17 Mar 2012 19:05:24 -0400, Simen Kjærås wrote: As for a workaround, have you considered using a simple array instead of a linked list? Arrays in D, especially when combined with std.array, make for easy-to-use (though perhaps not particularly efficient) stacks: int[] stack; sta

Re: Tail call optimization?

2012-03-19 Thread Alex Rønne Petersen
On 19-03-2012 13:07, bearophile wrote: Stewart Gordon: What are "normal cases"? It means "very simple cases". Things like fibonacci / factorial functions that call themselves at the tail. Generally it's a fragile optimization, it's easy for it to not work/stop working. LLVM used to perform

Re: Tail call optimization?

2012-03-19 Thread bearophile
Stewart Gordon: > What are "normal cases"? It means "very simple cases". Things like fibonacci / factorial functions that call themselves at the tail. Generally it's a fragile optimization, it's easy for it to not work/stop working. LLVM used to perform this optimization, then it stopped worki

Re: Tail call optimization?

2012-03-19 Thread Stewart Gordon
On 18/03/2012 21:28, bearophile wrote: Alex Rønne Petersen Wrote: Does D to tail call optimization of any kind? The D standard doesn't require the D compiler to perform that optimization (unlike Scheme). Currently both DMD and LDC are able to perform tail call optimization in some normal ca

Re: regex issue

2012-03-19 Thread Dmitry Olshansky
On 19.03.2012 12:05, Dmitry Olshansky wrote: On 19.03.2012 6:50, Jay Norwood wrote: On Friday, 16 March 2012 at 03:36:12 UTC, Joshua Niehus wrote: Hello, Does anyone know why I would get different results between ctRegex and regex in the following snippet? Thanks, Josh I'm also having que

Re: regex issue

2012-03-19 Thread Dmitry Olshansky
On 19.03.2012 6:50, Jay Norwood wrote: On Friday, 16 March 2012 at 03:36:12 UTC, Joshua Niehus wrote: Hello, Does anyone know why I would get different results between ctRegex and regex in the following snippet? Thanks, Josh I'm also having questions about the matchers. From what I underst

Comparison issue

2012-03-19 Thread James Miller
Hey, I'm trying to do some vector based code, and my unittests started to fail on testing normalize. I'm using the standard algorithm, but the assert is always return false. I did some investigation, and can show that this program causes failure: import std.math : sqrt; import std.stdio :