Re: regex with literal (ie automatically replace '(' with '\(', etc) )

2013-05-29 Thread Timothee Cour
ok, here it is: https://github.com/timotheecour/dtools/blob/master/dtools/util/util.d#L78 simplified implementation and added missing escape symbols. Any symbol missing? I was basing myself based on http://dlang.org/phobos/std_regex.html, table entry '\c where c is one of', but that was incomplete

Re: Reading file as binary

2013-05-29 Thread Ali Çehreli
On 05/29/2013 09:00 PM, baws wrote: Erhm, why isnt this compiling guys? all i did was add your suggestions... :/ Your code compiles here with dmd 2.062 and v2.063-devel-f6d55a9-dirty. What is the compiler error in your case? The program has a run time error though: args[1] is an invalid acc

Re: Consume an entire range

2013-05-29 Thread Brad Anderson
On Thursday, 30 May 2013 at 04:30:11 UTC, Brad Anderson wrote: [snip] import std.stdio, std.algorithm, std.array; void eat(R)(R r) { while(!r.empty) { r.front; r.popFront; } } void main() { size_t[dstring] dic; stdin.byLine .joiner(" ") .array .splitter('

Re: Consume an entire range

2013-05-29 Thread Brad Anderson
On Thursday, 30 May 2013 at 04:12:56 UTC, Diggory wrote: On Thursday, 30 May 2013 at 03:53:06 UTC, Brad Anderson wrote: On Thursday, 30 May 2013 at 03:50:52 UTC, Brad Anderson wrote: Is there a simple way to consume a range apart from std.array.array? I don't need to result of the range stored

Re: Consume an entire range

2013-05-29 Thread Brad Anderson
On Thursday, 30 May 2013 at 04:00:39 UTC, Jonathan M Davis wrote: On Thursday, May 30, 2013 05:53:02 Brad Anderson wrote: On Thursday, 30 May 2013 at 03:50:52 UTC, Brad Anderson wrote: > Is there a simple way to consume a range apart from > std.array.array? I don't need to result of the range s

Re: Consume an entire range

2013-05-29 Thread Diggory
On Thursday, 30 May 2013 at 04:18:14 UTC, Jonathan M Davis wrote: On Thursday, May 30, 2013 06:12:51 Diggory wrote: On Thursday, 30 May 2013 at 03:53:06 UTC, Brad Anderson wrote: > On Thursday, 30 May 2013 at 03:50:52 UTC, Brad Anderson > wrote: >> Is there a simple way to consume a range apar

Re: Consume an entire range

2013-05-29 Thread Jonathan M Davis
On Thursday, May 30, 2013 06:12:51 Diggory wrote: > On Thursday, 30 May 2013 at 03:53:06 UTC, Brad Anderson wrote: > > On Thursday, 30 May 2013 at 03:50:52 UTC, Brad Anderson wrote: > >> Is there a simple way to consume a range apart from > >> std.array.array? I don't need to result of the range s

Re: Consume an entire range

2013-05-29 Thread Diggory
On Thursday, 30 May 2013 at 03:53:06 UTC, Brad Anderson wrote: On Thursday, 30 May 2013 at 03:50:52 UTC, Brad Anderson wrote: Is there a simple way to consume a range apart from std.array.array? I don't need to result of the range stored in an array, I just need a lazy map to evaluate complete

Re: Reading file as binary

2013-05-29 Thread baws
On Wednesday, 29 May 2013 at 22:03:24 UTC, baws wrote: Im trying to learn D, lovely language for a C++ lover. I have a file Im trying to parse, but I need to read the contents as binary data. I also need help understanding how read() works. I'd like to read the first four bytes which identify t

Re: Consume an entire range

2013-05-29 Thread Jonathan M Davis
On Thursday, May 30, 2013 05:53:02 Brad Anderson wrote: > On Thursday, 30 May 2013 at 03:50:52 UTC, Brad Anderson wrote: > > Is there a simple way to consume a range apart from > > std.array.array? I don't need to result of the range stored in > > an array, I just need a lazy map to evaluate compl

Consume an entire range

2013-05-29 Thread Brad Anderson
Is there a simple way to consume a range apart from std.array.array? I don't need to result of the range stored in an array, I just need a lazy map to evaluate completely.

Re: Consume an entire range

2013-05-29 Thread Brad Anderson
On Thursday, 30 May 2013 at 03:50:52 UTC, Brad Anderson wrote: Is there a simple way to consume a range apart from std.array.array? I don't need to result of the range stored in an array, I just need a lazy map to evaluate completely. Obviously I could just popFront. To be more clear, I want

Re: regex with literal (ie automatically replace '(' with '\(', etc) )

2013-05-29 Thread Diggory
On Wednesday, 29 May 2013 at 23:33:30 UTC, timotheecour wrote: something like this, which we should have in std.regex: string escapeRegex(string a){ import std.string; enum transTable = ['[' : `\[`, '|' : `\|`, '*': `\*`, '+': `\+`, '?': `\?`, '(': `\(`, ')': `\)`]; return tra

Re: regex with literal (ie automatically replace '(' with '\(', etc) )

2013-05-29 Thread timotheecour
something like this, which we should have in std.regex: string escapeRegex(string a){ import std.string; enum transTable = ['[' : `\[`, '|' : `\|`, '*': `\*`, '+': `\+`, '?': `\?`, '(': `\(`, ')': `\)`]; return translate(a, transTable); } string escapeRegexReplace(string a){

regex with literal (ie automatically replace '(' with '\(', etc) )

2013-05-29 Thread Timothee Cour
See below: import std.stdio; import std.regex; void main(){ "h(i".replace!(a=>a.hit~a.hit)(regex(`h\(`,"g")).writeln; //this works, but I need to specify the escape manually // "h(i".replace!(a=>a.hit~a.hit)(regex(`h(`,"gl")).writeln; //I'd like this to work with a flag, say 'l' (lowercase L) as

regex with literal (ie automatically replace '(' with '\(', etc) )

2013-05-29 Thread timotheecour
See below: import std.stdio; import std.regex; void main(){ "h(i".replace!(a=>a.hit~a.hit)(regex(`h\(`,"g")).writeln; //this works, but I need to specify the escape manually // "h(i".replace!(a=>a.hit~a.hit)(regex(`h(`,"gl")).writeln; //I'd like this to work with a flag, say 'l' (lowercase L

Re: Reading file as binary

2013-05-29 Thread Ali Çehreli
On 05/29/2013 04:11 PM, bearophile wrote: > Ali Çehreli: > >> writefln("0x%(%x%)", a); > > But usually I prefer to show all the zero nibbles: > writefln("0x%(%02x%)", a); // Output: 0xa10207b And only then the output would make sense. Thanks. :) Ali

Re: Reading file as binary

2013-05-29 Thread bearophile
void main() { import std.stdio; ubyte[] a = [10, 16, 32, 123]; writefln("0x%(%02x%)", a); // Output: 0xa10207b static assert(is(typeof(a[0]) == ubyte), "Only ubyte[]"); writefln("0x%(%x%)", a); // Output: 0x0a10207b } I have pasted the outputs inverted, sorry. Bye, bearoph

Re: Reading file as binary

2013-05-29 Thread bearophile
Ali Çehreli: writefln("0x%(%x%)", a); But usually I prefer to show all the zero nibbles: void main() { import std.stdio; ubyte[] a = [10, 16, 32, 123]; writefln("0x%(%02x%)", a); // Output: 0xa10207b static assert(is(typeof(a[0]) == ubyte), "Only ubyte[]"); writefln("0

Re: Reading file as binary

2013-05-29 Thread Ali Çehreli
On 05/29/2013 03:23 PM, Adam D. Ruppe wrote: byte[] a = [10, 16, 32, 123]; writef("0x"); foreach(b; a) writef("%x", b); writef("\n"); There is also the nested array formatting. Pretty cool but dyslecix! :) writefln("0x%(%x%)", a); Ali

Re: Reading file as binary

2013-05-29 Thread Adam D. Ruppe
On Wednesday, 29 May 2013 at 22:03:24 UTC, baws wrote: With my code, im getting the integer values, If i use cast(byte[]) on read and writefln("Reading header info: 0x%x", bytesRead[0]); You're reading the file correctly, just not printing it all out in hex. writefln("Reading header in

Re: Reading file as binary

2013-05-29 Thread baws
On Wednesday, 29 May 2013 at 22:03:24 UTC, baws wrote: Im trying to learn D, lovely language for a C++ lover. I have a file Im trying to parse, but I need to read the contents as binary data. I also need help understanding how read() works. I'd like to read the first four bytes which identify t

Reading file as binary

2013-05-29 Thread baws
Im trying to learn D, lovely language for a C++ lover. I have a file Im trying to parse, but I need to read the contents as binary data. I also need help understanding how read() works. I'd like to read the first four bytes which identify the file header, I need it to show as a sequence of byte

Re: Linker error

2013-05-29 Thread alex
On Wednesday, 29 May 2013 at 21:17:29 UTC, Namespace wrote: Why is the phobos lib automatically detected with dmd 2.062 , but not with 2.063? I dunno, I suspected the sc.ini to be modified in some way, but surprisingly nothing changed in there. Anyway I just built a trivial sample program w/o

Re: Linker error

2013-05-29 Thread Namespace
Why is the phobos lib automatically detected with dmd 2.062 , but not with 2.063?

Re: Linker error

2013-05-29 Thread alex
On Wednesday, 29 May 2013 at 06:19:33 UTC, Namespace wrote: Davis (Debug) wird erzeugt pragma(lib, "D:\\D\\dmd2\\windows\\lib\\phobos.lib"); Might help. Please try to define this somewhere in your code - specifying the library in the project might also be sufficient.

Re: Is typeinfo documented on the website?

2013-05-29 Thread Adam D. Ruppe
On Wednesday, 29 May 2013 at 17:57:38 UTC, Namespace wrote: http://dlang.org/phobos/object.html#.TypeInfo_Class ah thanks, my eyes seem to skip right over that object link.

Re: Is typeinfo documented on the website?

2013-05-29 Thread Namespace
On Wednesday, 29 May 2013 at 17:54:12 UTC, Adam D. Ruppe wrote: I can't find it - everything I know about typeinfo is from reading druntime's source! The TypeInfo classes look useful but it is kinda hard to get it all from just the source. http://dlang.org/phobos/object.html#.TypeInfo_Class

Is typeinfo documented on the website?

2013-05-29 Thread Adam D. Ruppe
I can't find it - everything I know about typeinfo is from reading druntime's source! The TypeInfo classes look useful but it is kinda hard to get it all from just the source.

Duplicating multidimensional array

2013-05-29 Thread Joseph Rushton Wakeling
Hello all, I've been having some trouble trying to work out how to effectively duplicate a multidimensional array in a way that preserves type qualifiers. Now, obviously if we have a multidimensional array such as T[][] then calling .dup will duplicate only the base array; so if we do something l

Re: Linker error

2013-05-29 Thread Namespace
Solution: pragma(lib, "D:\\D\\dmd2\\windows\\lib\\phobos.lib"); I have to link the phobos lib by myself. o.O

Re: static const and user attribute

2013-05-29 Thread Ali Çehreli
On 05/29/2013 06:32 AM, Jack Applegame wrote: > I'm sorry. My english is terrible. Please don't say that. :) Your English is very nice and I am sure everybody here appreciates that you write in English. Ali

Re: static const and user attribute

2013-05-29 Thread bearophile
Kenji Hara: Please file it in bugzilla. Kenji Hara OK, I'll add it a bit later :-) Bye, bearophile

Re: static const and user attribute

2013-05-29 Thread Kenji Hara
On Wednesday, 29 May 2013 at 14:50:36 UTC, bearophile wrote: Dicebot: I think this is a bug. It will be fixed progressively in the next two or three DMD versions. Bye, bearophile Please file it in bugzilla. Kenji Hara

Re: static const and user attribute

2013-05-29 Thread bearophile
Dicebot: I think this is a bug. It will be fixed progressively in the next two or three DMD versions. Bye, bearophile

Re: static const and user attribute

2013-05-29 Thread Dicebot
On Wednesday, 29 May 2013 at 13:30:12 UTC, Jack Applegame wrote: Which difference between enum and static const with initializer? enum is pure compile-time entity. It does not take space or have a location, it is just a named value. "static const x = 42" is a thread-local variable which is in

Re: static const and user attribute

2013-05-29 Thread bearophile
Jack Applegame: Which difference between enum and static const with initializer? Currently nearly none. But it will be fixed in two or three DMD versions, and they will become const and enum. Bye, bearophile

Re: static const and user attribute

2013-05-29 Thread Jack Applegame
I'm sorry. My english is terrible.

static const and user attribute

2013-05-29 Thread Jack Applegame
Which difference between enum and static const with initializer? struct A { @("enum") enum int c1 = 10; @("const") static const int c2 = 20; } static assert(__traits(getAttributes, A.c1)[0] == "enum"); static assert(__traits(getAttributes, A.c2)[0] == "const"); // error http://dpaste.

Re: Where does the log get written when there's a core dump?

2013-05-29 Thread Dicebot
On Tuesday, 28 May 2013 at 21:15:55 UTC, Adam D. Ruppe wrote: ... Also worth noting that if your distro uses systemd, than core dumps by default are written to journal and managed via coredumpctl : http://www.freedesktop.org/software/systemd/man/systemd-coredumpctl.html

Re: Where does the log get written when there's a core dump?

2013-05-29 Thread Gary Willoughby
On Tuesday, 28 May 2013 at 21:15:55 UTC, Adam D. Ruppe wrote: On Tuesday, 28 May 2013 at 21:06:14 UTC, Gary Willoughby wrote: playing and I got a message of a seg fault and a core dump written to a log. like this? Segmentation fault (core dumped) That's actually more of a linux thing than a

Re: Is this a compiler bug, or a breaking fix/enhancement?

2013-05-29 Thread estew
This is a compiler regression in 2.063 release. http://d.puremagic.com/issues/show_bug.cgi?id=10197 Kenji Hara Thanks for looking into it. Stewart