Re: std.xml: Why is it so slow? Is there anything else wrong with it?

2011-03-13 Thread Russel Winder
On Sat, 2011-03-12 at 23:34 -0500, dsimcha wrote: There seems to be a consensus around here that Phobos needs a good XML module, and that std.xml doesn't cut it, at least partly due to performance issues. I have no clue how to write a good XML module from scratch. It seems like noone else

Re: std.xml: Why is it so slow? Is there anything else wrong with it?

2011-03-13 Thread Jonathan M Davis
On Sunday 13 March 2011 01:11:05 Russel Winder wrote: On Sat, 2011-03-12 at 23:34 -0500, dsimcha wrote: There seems to be a consensus around here that Phobos needs a good XML module, and that std.xml doesn't cut it, at least partly due to performance issues. I have no clue how to write a

string need to be robust

2011-03-13 Thread ZY Zhou
Hi, I wrote a small program to read and parse html(charset=UTF-8). It worked great until some invalid utf8 chars appears in that page. When the string is invalid, things like foreach or std.string.tolower will just crash. this make the string type totally unusable when processing files, since

Re: string need to be robust

2011-03-13 Thread Jonathan M Davis
On Sunday 13 March 2011 01:57:12 ZY Zhou wrote: Hi, I wrote a small program to read and parse html(charset=UTF-8). It worked great until some invalid utf8 chars appears in that page. When the string is invalid, things like foreach or std.string.tolower will just crash. this make the string

Re: string need to be robust

2011-03-13 Thread ZY Zhou
std.utf throw exception instead of crash the program. but you still need to add try/catch everywhere. My point is: this simple code should work, instead of crash, it is supposed to leave all invalid codes untouched and just process the valid parts. Stream file = new BufferedFile(sample.txt);

Re: string need to be robust

2011-03-13 Thread Jonathan M Davis
On Sunday 13 March 2011 04:34:24 ZY Zhou wrote: std.utf throw exception instead of crash the program. but you still need to add try/catch everywhere. My point is: this simple code should work, instead of crash, it is supposed to leave all invalid codes untouched and just process the valid

Re: string need to be robust

2011-03-13 Thread %u
== Quote from ZY Zhou (rin...@geemail.com)'s article std.utf throw exception instead of crash the program. but you still need to add try/catch everywhere. My point is: this simple code should work, instead of crash, it is supposed to leave all invalid codes untouched and just process the

Re: string need to be robust

2011-03-13 Thread spir
On 03/13/2011 10:57 AM, ZY Zhou wrote: Hi, I wrote a small program to read and parse html(charset=UTF-8). It worked great until some invalid utf8 chars appears in that page. When the string is invalid, things like foreach or std.string.tolower will just crash. this make the string type totally

Re: string need to be robust

2011-03-13 Thread ZY Zhou
but I think that it's completely unreasonable to expect all of the string-based and/or range-based functions to be able to handle invalid unicode. As I explained in the first mail, if utf8 parser convert all invalid utf8 chars to low surrogate code points(0x80~0xFF - 0xDC80~0xDCFF), other

Re: string need to be robust

2011-03-13 Thread spir
On 03/13/2011 12:34 PM, ZY Zhou wrote: std.utf throw exception instead of crash the program. but you still need to add try/catch everywhere. My point is: this simple code should work, instead of crash, it is supposed to leave all invalid codes untouched and just process the valid parts. Stream

Re: string need to be robust

2011-03-13 Thread spir
On 03/13/2011 01:25 PM, ZY Zhou wrote: but I think that it's completely unreasonable to expect all of the string-based and/or range-based functions to be able to handle invalid unicode. As I explained in the first mail, if utf8 parser convert all invalid utf8 chars to low surrogate code

Re: string need to be robust

2011-03-13 Thread spir
On 03/13/2011 01:25 PM, ZY Zhou wrote: but I think that it's completely unreasonable to expect all of the string-based and/or range-based functions to be able to handle invalid unicode. As I explained in the first mail, if utf8 parser convert all invalid utf8 chars to low surrogate code

Re: string need to be robust

2011-03-13 Thread ZY Zhou
What if I'm making a text editor with D? I know the text has something wrong, I want to open it and fix it. the exception won't help, if the editor just refuse to open invalid file, then the editor is useless. Try open an invalid utf file with a text editor, like vim, you will understand what I

Re: string need to be robust

2011-03-13 Thread Michel Fortin
On 2011-03-13 10:18:24 -0400, ZY Zhou rin...@geeemail.com said: What if I'm making a text editor with D? I know the text has something wrong, I want to open it and fix it. the exception won't help, if the editor just refuse to open invalid file, then the editor is useless. Try open an invalid

Re: string need to be robust

2011-03-13 Thread ZY Zhou
If a invalid utf8 or utf16 code need to be converted to utf32, then it should be converted to an invalid utf32. that's why D800~DFFF are marked as invalid points in unicode standard. == Quote from spir (denis.s...@gmail.com)'s article This is not a good idea, imo. Surrogate values /are/ invalid

If invalid string should crash(was:string need to be robust)

2011-03-13 Thread ZY Zhou
Hi, invalid utf8 code always break my program, so I suggest if invalid code in utf8 need to be converted to dchar, use the low surrogate code points(DC80~DCFF) instead of crashing the program. But many people here don't like this idea, you think exception is the right thing. OK, let me ask you a

Re: Derailed (Was: Code Sandwiches)

2011-03-13 Thread gölgeliyele
On 3/12/11 11:10 PM, Andrej Mitrovic wrote: On 3/13/11, Nick Sabalauskya@a.a wrote: snip OSX is a nice OS. I gave it a try once or twice. The OS is nice, but man, when I started looking for software on the web I almost got sick. Top 10 software for Your Mac, 5 Apps that will make your Mac

Re: Derailed (Was: Code Sandwiches)

2011-03-13 Thread Andrej Mitrovic
On 3/13/11, gölgeliyele usul...@gmail.com wrote: If you are a linux person, you may like Mac ports. I use a large number of linux apps on my Mac, such as GIMP, GNU emacs, Inkscape, vncviewer, etc. MacVim looks nice. I've also heard great things about Textmate. There's definitely nice software

SQLite Bindings

2011-03-13 Thread dsimcha
One of the features I miss most in Phobos is support for SQLite. Several people have written bindings and wrappers and haven't gotten much attention. (For example: https://github.com/bayun/SQLite3-D ). IMHO, we should do the following: 1. Put SQLite bindings and the C code (which is public

Re: SQLite Bindings

2011-03-13 Thread Bane
That is great idea. I already hove something similar i n library I use for work, bunch of headers converted for D, from opeanAL to libpq (postgres), sqlite etc. That can be placed in both D1 and D2 without any problem.

Re: Curl support RFC

2011-03-13 Thread Jesse Phillips
Jonas Drewsen Wrote: Just tried the property stuff out but it seems a bit inconsistent. Maybe someone can enlighten me: import std.stdio; alias void delegate() deleg; class T { private deleg tvalue; @property void prop(deleg dg) { tvalue = dg; } @property deleg

Re: string need to be robust

2011-03-13 Thread Jacob Carlborg
On 2011-03-13 13:22, spir wrote: On 03/13/2011 10:57 AM, ZY Zhou wrote: Hi, I wrote a small program to read and parse html(charset=UTF-8). It worked great until some invalid utf8 chars appears in that page. When the string is invalid, things like foreach or std.string.tolower will just crash.

Re: string need to be robust

2011-03-13 Thread spir
On 03/13/2011 04:43 PM, ZY Zhou wrote: If a invalid utf8 or utf16 code need to be converted to utf32, then it should be converted to an invalid utf32. that's why D800~DFFF are marked as invalid points in unicode standard. You are wrong on both points. First, there is no definition of invalid

Re: string need to be robust

2011-03-13 Thread Andrei Alexandrescu
On 3/13/11 1:55 PM, Jacob Carlborg wrote: I would say that the functions should NOT crash but instead throw an exception. Then the developer can choose what to do when there's an invalid unicode character. Yah. In addition, the exception should provide index information such that an

Re: string need to be robust

2011-03-13 Thread Andrej Mitrovic
Crash - Have fun stepping through your code with a debugger, or worse, observe disassembly. Throw - (Hopefully) get an informative error message, which could mean you'll be able to fix the bug quickly.

Re: Curl support RFC

2011-03-13 Thread Jonas Drewsen
Hi, So I've been working a bit on the etc.curl module. Currently most of the HTTP functionality is done and some very simple Ftp. I would very much like to know if this has a chance of getting in phobos if I finish it with the current design. If not then it will be for my own project only

Re: SQLite Bindings

2011-03-13 Thread Jonas Drewsen
On 13/03/11 18.29, dsimcha wrote: One of the features I miss most in Phobos is support for SQLite. Several people have written bindings and wrappers and haven't gotten much attention. (For example: https://github.com/bayun/SQLite3-D ). IMHO, we should do the following: 1. Put SQLite bindings

Re: SQLite Bindings

2011-03-13 Thread Daniel Gibson
Am 13.03.2011 18:29, schrieb dsimcha: One of the features I miss most in Phobos is support for SQLite. Several people have written bindings and wrappers and haven't gotten much attention. (For example: https://github.com/bayun/SQLite3-D ). IMHO, we should do the following: 1. Put SQLite

Re: Curl support RFC

2011-03-13 Thread Andrei Alexandrescu
On 3/11/11 9:20 AM, Jonas Drewsen wrote: Hi, So I've spent some time trying to wrap libcurl for D. There is a lot of things that you can do with libcurl which I did not know so I'm starting out small. For now I've created all the declarations for the latest public curl C api. I have put that

Re: SQLite Bindings

2011-03-13 Thread Jonathan M Davis
On Sunday 13 March 2011 14:56:34 Jonas Drewsen wrote: On 13/03/11 18.29, dsimcha wrote: One of the features I miss most in Phobos is support for SQLite. Several people have written bindings and wrappers and haven't gotten much attention. (For example: https://github.com/bayun/SQLite3-D ).

Re: Google Summer of Code 2011 application

2011-03-13 Thread Nebster
On 12/03/2011 17:23, Daniel Gibson wrote: No reason to hate Tango. Ok, I don't really hate Tango, I just prefer Phobos because I got used to it first :)

Re: Google Summer of Code 2011 application

2011-03-13 Thread Daniel Gibson
Am 14.03.2011 02:21, schrieb Nebster: On 12/03/2011 17:23, Daniel Gibson wrote: No reason to hate Tango. Ok, I don't really hate Tango, I just prefer Phobos because I got used to it first :) This is perfectly fine :) Just don't feed the trolls and don't let them provoke baseless insults ;)

Re: If invalid string should crash(was:string need to be robust)

2011-03-13 Thread %u
But for the following case, it is complete wrong if it crash at line 3: 1: char[] c = [0xA0]; 2: string s = c.idup; 3: foreach(dchar d; s){} The expected result is either: a) crash at line 2, c is not valid utf and can't be converted to string or: b) don't crash, and d = 0xDCA0; I

Re: SQLite Bindings

2011-03-13 Thread dsimcha
On 3/13/2011 5:56 PM, Jonas Drewsen wrote: It's a great idea. But I think there need to be some kind of janitor for the 'etc' modules so that it does not end up as a new dsource collection of many unmaintained, some dead and a few live projects. I don't see why this is a concern. This is what

Re: SQLite Bindings

2011-03-13 Thread Andrej Mitrovic
Wrapping is also bug-prone. htod could fail to translate a header file perfectly, and it won't work good with macros. E.g.: http://stackoverflow.com/questions/5204460/problems-converting-a-c-header-to-d . You could accidentally put the wrong calling convention (or rather, htod will), and this will

Re: SQLite Bindings

2011-03-13 Thread Jesse Phillips
libcurl, SQLite, libpng, libbzip2, and the WindowsAPI stuff all sound like Excellent items to include for standard distribution. It is really nice to just have these items available like zlib and zip. Personally I think Lua would make a nice standard extension language, but the license is

Re: string need to be robust

2011-03-13 Thread ZY Zhou
it doesn't make sense to add try/catch every time you use tolower/toupper/foreach on string. No one will do that. You either throw exception when convert invalid utf8 bytes to string, or never throw exception and use invalid UTF32 code in dchar to represent invalid utf8 code. string s = \x0A;

Re: string need to be robust

2011-03-13 Thread Jesse Phillips
KennyTM~ Wrote: It is already throwing an exception called core.exception.UnicodeException. This even provides you the index where decoding failed. (However Phobos is not using it, AFAIK.) --- import core.exception, std.stdio, std.conv; void main() { char[] s = [0x0f,

How do you debug DMD?

2011-03-13 Thread %u
I tried using Visual Studio to set breakpoints in DMD and everything (after compiling with -g), but it said that the source file is a different version (it isn't), and so it doesn't really let me set breakpoints. What tools (aka debuggers) do you guys use to debug DMD? Any free tools we can use

Re: Points and Vectors in 3D

2011-03-13 Thread Spacen Jasset
On 13/03/2011 00:06, Bekenn wrote: On 3/12/2011 2:20 PM, Simon wrote: I've done lots of 3d over the years and used quite a lot of different libraries and I've come to prefer code that makes a distinction between points and vectors. Agreed. This has some nice benefits with operator

Re: Ranges

2011-03-13 Thread spir
On 03/13/2011 01:05 AM, Jonathan M Davis wrote: If you were to try and iterate over a char[] by char, then you would be looking at code units rather than code points which is _rarely_ what you want. If you're dealing with anything other than pure ASCII, you _will_ have bugs if you do that.

Re: Points and Vectors in 3D

2011-03-13 Thread Simen kjaeraas
Spacen Jasset spacenjas...@yahoo.co.uk wrote: On 13/03/2011 00:06, Bekenn wrote: On 3/12/2011 2:20 PM, Simon wrote: I've done lots of 3d over the years and used quite a lot of different libraries and I've come to prefer code that makes a distinction between points and vectors. Agreed. This

Re: Points and Vectors in 3D

2011-03-13 Thread Simon
On 13/03/2011 14:11, Simen kjaeraas wrote: Spacen Jasset spacenjas...@yahoo.co.uk wrote: On 13/03/2011 00:06, Bekenn wrote: On 3/12/2011 2:20 PM, Simon wrote: I've done lots of 3d over the years and used quite a lot of different libraries and I've come to prefer code that makes a distinction

Re: Points and Vectors in 3D

2011-03-13 Thread Simen kjaeraas
On Sun, 13 Mar 2011 15:43:09 +0100, Simon s.d.hamm...@gmail.com wrote: On 13/03/2011 14:11, Simen kjaeraas wrote: Spacen Jasset spacenjas...@yahoo.co.uk wrote: On 13/03/2011 00:06, Bekenn wrote: On 3/12/2011 2:20 PM, Simon wrote: I've done lots of 3d over the years and used quite a lot of

Re: Points and Vectors in 3D

2011-03-13 Thread Caligo
On Sun, Mar 13, 2011 at 9:11 AM, Simen kjaeraas simen.kja...@gmail.comwrote: Spacen Jasset spacenjas...@yahoo.co.uk wrote: Can't see a fitting operator in D. Multiplication (*) is ambiguous at best and no other operator seems fitting. I agree. It's just better do define 'dot' and 'cross'.

Re: Points and Vectors in 3D

2011-03-13 Thread Simon
On 13/03/2011 15:29, Simen kjaeraas wrote: On Sun, 13 Mar 2011 15:43:09 +0100, Simon s.d.hamm...@gmail.com wrote: Convention is to use ^ as cross product and * as dot product. Really? I've never heard of it. Rather, everyone I've talked to about it has said exactly what I did.

foo.bar !in baz not allowed?

2011-03-13 Thread Magnus Lie Hetland
For some reason, it seems like expressions of the form foo.bar !in baz aren't allowed. I suspect this is a grammar/parser problem -- the bang is interpreted as a template argument operator, rather than a negation operator, and there's really no need to make that interpretation when it is

Re: foo.bar !in baz not allowed?

2011-03-13 Thread spir
On 03/13/2011 07:58 PM, Magnus Lie Hetland wrote: For some reason, it seems like expressions of the form foo.bar !in baz aren't allowed. I suspect this is a grammar/parser problem -- the bang is interpreted as a template argument operator, rather than a negation operator, and there's really no

Re: foo.bar !in baz not allowed?

2011-03-13 Thread Magnus Lie Hetland
On 2011-03-13 21:27:27 +0100, spir said: On 03/13/2011 07:58 PM, Magnus Lie Hetland wrote: For some reason, it seems like expressions of the form foo.bar !in baz aren't allowed. I suspect this is a grammar/parser problem -- the bang is interpreted as a template argument operator, rather than a

Semi-const methods?

2011-03-13 Thread Magnus Lie Hetland
I have a data structure that's generally static (const, or even immutable), but it has some utility storage, which caches certain results during use. This caching etc. doesn't really affect the semantics of the main object, and are reset between operations, so I think it still would be useful

Re: Semi-const methods?

2011-03-13 Thread Magnus Lie Hetland
On 2011-03-13 23:27:14 +0100, Magnus Lie Hetland said: Any other ideas on how to handle this sort of mostly const or const where it counts stuff? Perhaps my design intentions here are off to begin with?-) OK -- a *little* quick on the trigger there. My solution: Declare the method const,

Re: Semi-const methods?

2011-03-13 Thread Magnus Lie Hetland
On 2011-03-13 23:32:34 +0100, Magnus Lie Hetland said: (Still open to schooling on the design part of this, though. Perhaps declaring a method as const is no good when it's not *really* const? For now, I'm just doing it to check that I don't inadvertently change things I don't want to

Re: Semi-const methods?

2011-03-13 Thread Jonathan M Davis
On Sunday 13 March 2011 15:32:34 Magnus Lie Hetland wrote: On 2011-03-13 23:27:14 +0100, Magnus Lie Hetland said: Any other ideas on how to handle this sort of mostly const or const where it counts stuff? Perhaps my design intentions here are off to begin with?-) OK -- a *little* quick

Dependencies file format

2011-03-13 Thread Bekenn
After some searching, I found the documentation here: http://d.puremagic.com/issues/show_bug.cgi?id=3122 Shouldn't this be on the web site somewhere?

Help passing D strings to C libs

2011-03-13 Thread Gene P. Cross
Hi, I'm fairly new to D and I'm writing a Space Invaders clone to get myself acquainted with the language. I'm having trouble passing D strings (char[]) to SDL, in particular SDL_LoadBMP(), I keep receiving a segfault. Heres the code: void setImg(string path) { // concat null terminating

Re: Help passing D strings to C libs

2011-03-13 Thread Andrej Mitrovic
Use toStringz from std.string, ala: SDL_LoadBMP(toStringz(path)); Do not embed nulls before calling toStringz, so remove 'path ~= \0;'

Re: Help passing D strings to C libs

2011-03-13 Thread Andrej Mitrovic
Wait, actually I'm not sure if there's toStringz for D1, it is there for D2. Try it out, I guess.

Re: Help passing D strings to C libs

2011-03-13 Thread Gene P. Cross
toStringz is in D1 but still no luck, I still get the same error Thanks for the suggestion though

Re: Help passing D strings to C libs

2011-03-13 Thread Jonathan M Davis
On Sunday 13 March 2011 21:32:49 Gene P. Cross wrote: Hi, I'm fairly new to D and I'm writing a Space Invaders clone to get myself acquainted with the language. I'm having trouble passing D strings (char[]) to SDL, in particular SDL_LoadBMP(), I keep receiving a segfault. Heres the code:

Re: Help passing D strings to C libs

2011-03-13 Thread Gene P. Cross
I've amended the source to pass the strings pointer (path.ptr) after adding a null but the problem still persists. I lost for what it could be and I'm certain this is where the problem is, because if I remove the method call, the program runs fine. I've noticed that calling SDL_LoadBMP and

[Issue 5733] New: Calling opDispatch As Template Results in Compiler Infinite Loop

2011-03-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5733 Summary: Calling opDispatch As Template Results in Compiler Infinite Loop Product: D Version: D2 Platform: All OS/Version: Windows Status: NEW Severity: