Re: Lexer in D

2013-03-02 Thread Dmitry Olshansky
03-Mar-2013 03:12, Namespace пишет: I noted it to late: decode comes from readText: readText validates your text. I will now use std.file.read. That's why Walter promotes profilers. They help verify hypothesis on performance and constantly surprise people in what they actually find. The n

Re: Lexer in D

2013-03-02 Thread Dmitry Olshansky
03-Mar-2013 03:52, Namespace пишет: I think that thanks to your suggestions isKeyword and isType are entirely inlined, because they aren't listet in the trace.log anymore (http://dpaste.1azy.net/b94b19ff). The only thing which makes trouble is the isNext function. Maybe I should also use a String

Re: Lexer in D

2013-03-02 Thread Namespace
I noted it to late: decode comes from readText: readText validates your text. I will now use std.file.read. The new trace output is here and it seems you're right, isKeyword and isType (yes I'd decided to separate it again and keep both in the lexer) take a lot of time: http://dpaste.1azy.ne

Re: Possible to view D strings in gdb?

2013-03-02 Thread Samuel Lampa
On 03/02/2013 11:56 PM, Samuel Lampa wrote: On 03/02/2013 11:52 PM, Samuel Lampa wrote: * DMD64 D Compiler v2.061(using flags "-gc") Ah, never mind! By giving these details I got myself thinking and read up on the man page to use "-g" and not "-gc". Problem solved! :) Very happily debuggin

Re: Lexer in D

2013-03-02 Thread Namespace
I never used the -profile flag before (only -conv) so I want to ask if I understand it right: http://dpaste.1azy.net/4382097b It seems that the call which is listed on line 133 1589328 214949 214948 0 pure @trusted dchar std.utf.decode!(const(immutable(char)[])).decode(r

Re: Possible to view D strings in gdb?

2013-03-02 Thread Samuel Lampa
On 03/02/2013 11:52 PM, Samuel Lampa wrote: * DMD64 D Compiler v2.061(using flags "-gc") Ah, never mind! By giving these details I got myself thinking and read up on the man page to use "-g" and not "-gc". Problem solved! :) Very happily debugging D with cgdb now! :) // Samuel

Re: Possible to view D strings in gdb?

2013-03-02 Thread Samuel Lampa
On 03/02/2013 11:33 PM, Samuel Lampa wrote: When using gdb to debug my d program, is there any way to correctly display the string variables? (I'm new to gdb, so I might have missed something?). Oh, and I have: * GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04 * Compiled with: *

Possible to view D strings in gdb?

2013-03-02 Thread Samuel Lampa
Hi, When using gdb to debug my d program, is there any way to correctly display the string variables? (I'm new to gdb, so I might have missed something?). if I do: print(myString), I will only get something like: $1 = 0x7fffe8970018 Best Regards // Samuel

Re: Lexer in D

2013-03-02 Thread Dmitry Olshansky
02-Mar-2013 23:50, Zach the Mystic пишет: On Saturday, 2 March 2013 at 11:59:39 UTC, Dmitry Olshansky wrote: 02-Mar-2013 15:04, David пишет: Am 02.03.2013 10:33, schrieb Namespace: For one of our courses this year we have a very cool topic: Lexer and Compiler. In the past I have already tried

Re: Lexer in D

2013-03-02 Thread Dmitry Olshansky
03-Mar-2013 00:03, Namespace пишет: This is a mess of conditionals is what a direct array of 256 entries would avoid: int idx; if (value[0] != '_') { idx = value[0] - 'a'; if (idx == 26) return false; } else { idx = 26; } if (idx < 0 || idx > 26) {

Re: Lexer in D

2013-03-02 Thread Namespace
It is sufficient if my array has only 26 units, because I check only lower cases.

Re: Ctor, setters and invariant

2013-03-02 Thread Simen Kjærås
On Sat, 02 Mar 2013 11:02:08 +0100, simendsjo wrote: invariant is called when a method enters. This creates problems if the constructor calls a setter: import std.exception; struct S { private int _i; public: this(int i) { this.i = i; } @property void i(int v) { enfo

Re: Lexer in D

2013-03-02 Thread Namespace
This is a mess of conditionals is what a direct array of 256 entries would avoid: int idx; if (value[0] != '_') { idx = value[0] - 'a'; if (idx == 26) return false; } else { idx = 26; } if (idx < 0 |

Re: Lexer in D

2013-03-02 Thread Zach the Mystic
On Saturday, 2 March 2013 at 11:59:39 UTC, Dmitry Olshansky wrote: 02-Mar-2013 15:04, David пишет: Am 02.03.2013 10:33, schrieb Namespace: For one of our courses this year we have a very cool topic: Lexer and Compiler. In the past I have already tried some experiments in this direction with

Re: Lexer in D

2013-03-02 Thread Dmitry Olshansky
02-Mar-2013 23:01, Namespace пишет: I hope I understand you right this time: http://dpaste.1azy.net/4c2e4428 Was this your idea? With this I reached between 215 and 230 msecs. This is a mess of conditionals is what a direct array of 256 entries would avoid: int idx; if (valu

Re: What xml libraries are people using?

2013-03-02 Thread Andrej Mitrovic
On 3/2/13, simendsjo wrote: > Which can you recommend? I use ae's lite xml library: https://github.com/CyberShadow/ae/blob/master/utils/xmllite.d It's not a monster but thanks to UFCS I can easily extend it to do what I want. For some trivial xml parsing which I needed it was great (OTOH std.xm

Re: Lexer in D

2013-03-02 Thread Dmitry Olshansky
02-Mar-2013 22:15, Dmitry Olshansky пишет: 02-Mar-2013 22:09, Namespace пишет: No-no and no. Just translate list of keywords/types to a bunch of switch-cases that will give you near optimal performance. Use CTFE to construct that string of D code. In fact I proposed to do just 2 levels of switc

Re: Lexer in D

2013-03-02 Thread Dmitry Olshansky
02-Mar-2013 22:09, Namespace пишет: No-no and no. Just translate list of keywords/types to a bunch of switch-cases that will give you near optimal performance. Use CTFE to construct that string of D code. In fact I proposed to do just 2 levels of switches: first switch by length then by first ch

Re: Lexer in D

2013-03-02 Thread Namespace
No-no and no. Just translate list of keywords/types to a bunch of switch-cases that will give you near optimal performance. Use CTFE to construct that string of D code. In fact I proposed to do just 2 levels of switches: first switch by length then by first char. I don't understand. You don'

Re: Passing a value by reference to function in taskPool

2013-03-02 Thread Sparsh Mittal
Thanks a lot for your reply.

unpredictableSeed

2013-03-02 Thread Joseph Rushton Wakeling
Hello all, Can anyone advise on the theoretical basis for the unpredictableSeed method in std.random? I've tried googling around for the theory of good thread-safe seed generation methods but haven't really found anything. :-( Thanks & best wishes, -- Joe

Re: What xml libraries are people using?

2013-03-02 Thread Jesse Phillips
On Saturday, 2 March 2013 at 08:03:08 UTC, simendsjo wrote: Everyone says "Don't use std.xml", and there are several other libraries. Which can you recommend? (I haven't looked closely at any of them, just some links found by googling) https://github.com/adamdruppe/misc-stuff-including-D-progr

Re: Lexer in D

2013-03-02 Thread Dmitry Olshansky
02-Mar-2013 18:53, Namespace пишет: That would be slower as canFind is linear search. Simpler way is use first letter and length to select a bucket of keywords. I think I get it. Did you mean something like this? No-no and no. Just translate list of keywords/types to a bunch of switch-cases

Re: What xml libraries are people using?

2013-03-02 Thread Russel Winder
I don't do XML working with D, but with Python. Actually I'd prefer never to have to work with XML at all but,… After many different Python oriented (either Python implemented or C coded Python extensions), the tide has now turned to simply using libxml2 and libxslt using an adaptor library, lxml.

Re: What xml libraries are people using?

2013-03-02 Thread Jacob Carlborg
On 2013-03-02 09:03, simendsjo wrote: Everyone says "Don't use std.xml", and there are several other libraries. Which can you recommend? (I haven't looked closely at any of them, just some links found by googling) https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuf

Re: What xml libraries are people using?

2013-03-02 Thread Adam D. Ruppe
I use the dom.d in the long misc github link. (I wrote it for myself) I find it very convenient but there are some downsides: 1) it is slow with large files 2) it eats a lot of memory, I think about 150 bytes per node, plus the actual data (text and attributes). A 1 MB xml file can easily eat

Re: Lexer in D

2013-03-02 Thread Namespace
That would be slower as canFind is linear search. Simpler way is use first letter and length to select a bucket of keywords. I think I get it. Did you mean something like this? [code] immutable ubyte[char] typeMap; immutable ubyte[char] keywordMap; static this() { typeMap = [ 'd' :

Re: Lexer in D

2013-03-02 Thread Namespace
I sorted both, types and keywords, alphabetical and wrote my own 'canFind': bool canFind(const size_t size)(ref const string[size] values, string value) pure nothrow { if (value[0] < 'm' || value[0] == '_') { foreach (string _val; values) { if (_

Re: Lexer in D

2013-03-02 Thread Namespace
With canFind it takes ~300 msecs. :/ Any idea how I could improve it? Simpler way is use first letter and length to select a bucket of keywords. I don't understand how you could do this without AA's and how this could be more performant than canFind.

Re: Ctor, setters and invariant

2013-03-02 Thread Maxim Fomin
Make a property private?

Re: Lexer in D

2013-03-02 Thread Dmitry Olshansky
02-Mar-2013 15:04, David пишет: Am 02.03.2013 10:33, schrieb Namespace: For one of our courses this year we have a very cool topic: Lexer and Compiler. In the past I have already tried some experiments in this direction with Romulus and Remus, but I've never measured my Lexing time. That's why I

Re: Lexer in D

2013-03-02 Thread David
Am 02.03.2013 10:33, schrieb Namespace: > For one of our courses this year we have a very cool topic: Lexer and > Compiler. > In the past I have already tried some experiments in this direction with > Romulus and Remus, but I've never measured my Lexing time. > That's why I wanted to start again to

Re: Lexer in D

2013-03-02 Thread Namespace
I'm already using these flags. But thanks for your Link I will take a look at it. :)

Re: Lexer in D

2013-03-02 Thread Dmitry Olshansky
02-Mar-2013 13:33, Namespace пишет: For one of our courses this year we have a very cool topic: Lexer and Compiler. In the past I have already tried some experiments in this direction with Romulus and Remus, but I've never measured my Lexing time. That's why I wanted to start again to write a lex

Re: What xml libraries are people using?

2013-03-02 Thread Dicebot
On Saturday, 2 March 2013 at 08:03:08 UTC, simendsjo wrote: Everyone says "Don't use std.xml", and there are several other libraries. Which can you recommend? (I haven't looked closely at any of them, just some links found by googling) https://github.com/adamdruppe/misc-stuff-including-D-progr

Ctor, setters and invariant

2013-03-02 Thread simendsjo
invariant is called when a method enters. This creates problems if the constructor calls a setter: import std.exception; struct S { private int _i; public: this(int i) { this.i = i; } @property void i(int v) { enforce(v > 1); _i = v; } invariant() { assert(_i > 1);

Lexer in D

2013-03-02 Thread Namespace
For one of our courses this year we have a very cool topic: Lexer and Compiler. In the past I have already tried some experiments in this direction with Romulus and Remus, but I've never measured my Lexing time. That's why I wanted to start again to write a lexer (hitherto purely for the learni

Re: Aliasing specialized template stuct in his module leads troubles

2013-03-02 Thread Rob T
On Saturday, 2 March 2013 at 03:59:59 UTC, H. S. Teoh wrote: On Sat, Mar 02, 2013 at 04:17:10AM +0100, Rob T wrote: In my case, the problem had to do with the order in which I was linking my static libs, simply changing the order resolved the undefined references. Turns out it's a common problem

What xml libraries are people using?

2013-03-02 Thread simendsjo
Everyone says "Don't use std.xml", and there are several other libraries. Which can you recommend? (I haven't looked closely at any of them, just some links found by googling) https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/dom.d http://svn.dsourc