Searching for a string in a text buffer with a regular expression

2013-12-06 Thread maxpat78
While porting a simple Python script to D, I found the following problem. I need to read in some thousand of little text files and search every one for a match with a given regular expression. Obviously, the program can't (and it should not) be certain about the encoding of each input file.

Any netowork library, or libraries that support promiscuous mode?

2013-12-06 Thread Cabe
Just wondering if any library that supports putting network adapter in promiscuous mode. As I new to D and heard something about importing C libraries in to D, but I don't know how smooth that will be so just was wondering if any D libraries that support promiscuous mode. Thanks to anyone

Re: Searching for a string in a text buffer with a regular expression

2013-12-06 Thread bearophile
maxpat78: Is there a simple and elegant solution in D for such case? Python didn't gave such problems! Do you mean Python3? Bye, bearophile

Re: Unresolvable references to dlopen, dlclose etc

2013-12-06 Thread Mafi
On Thursday, 5 December 2013 at 19:20:16 UTC, Mafi wrote: I am on fresh install of Linux Mint 16 64bit and I tried to compile some D code I have writen and I have problems (Hello World works btw). I uses Derelict (v2) and I have successfully compiled/linked/rurn my program on Windows 7 64bit.

Re: Is this reasonable?

2013-12-06 Thread Fra
On Friday, 6 December 2013 at 02:11:20 UTC, Jonathan M Davis wrote: Regardless, we're pretty much stuck at this point. Changing it would silently break lots of code. I still wonder what was the reasoning behind C's warning about comparison between signed and unsigned integers instead of

Re: Searching for a string in a text buffer with a regular expression

2013-12-06 Thread Shammah Chancellor
On 2013-12-06 08:53:04 +, maxpat78 said: While porting a simple Python script to D, I found the following problem. I need to read in some thousand of little text files and search every one for a match with a given regular expression. Obviously, the program can't (and it should not) be

Re: Is this reasonable?

2013-12-06 Thread Jonathan M Davis
On Friday, December 06, 2013 12:02:29 Fra wrote: On Friday, 6 December 2013 at 02:11:20 UTC, Jonathan M Davis wrote: Regardless, we're pretty much stuck at this point. Changing it would silently break lots of code. I still wonder what was the reasoning behind C's warning about

Re: Is this reasonable?

2013-12-06 Thread Dominikus Dittes Scherkl
The best that could be done would arguably be to simply do the comparison the 'right' way. E.g. static assert(-1 0u). What's the 'right' way? assert(-1 uint.max) will always fail because no matter whether you convert to int or uint, the comparison simply cannot be carried out at the

Re: Is this reasonable?

2013-12-06 Thread Fra
On Friday, 6 December 2013 at 11:56:35 UTC, Jonathan M Davis wrote: There's no such thing as standard warnins in C. What gets warned about depends entirely on the compiler and what it's settings are. You are 100% right, I was speaking out of my mind. Anyway, I still don't understand the

Re: Any netowork library, or libraries that support promiscuous mode?

2013-12-06 Thread evilrat
On Friday, 6 December 2013 at 10:32:52 UTC, Cabe wrote: Just wondering if any library that supports putting network adapter in promiscuous mode. As I new to D and heard something about importing C libraries in to D, but I don't know how smooth that will be so just was wondering if any D

Re: Unresolvable references to dlopen, dlclose etc

2013-12-06 Thread Jacob Carlborg
On 2013-12-05 20:20, Mafi wrote: I am on fresh install of Linux Mint 16 64bit and I tried to compile some D code I have writen and I have problems (Hello World works btw). I uses Derelict (v2) and I have successfully compiled/linked/rurn my program on Windows 7 64bit. But on Linux I get errors

Re: Is this reasonable?

2013-12-06 Thread Timon Gehr
On 12/06/2013 02:06 AM, H. S. Teoh wrote: On Thu, Dec 05, 2013 at 10:06:55PM +0100, Timon Gehr wrote: On 12/05/2013 07:26 PM, Jonathan M Davis wrote: The best that could be done would be to warn about the comparison or to make it an error. http://d.puremagic.com/issues/show_bug.cgi?id=259 ...

Re: Unresolvable references to dlopen, dlclose etc

2013-12-06 Thread Mafi
You can compile with the verbose flag, -v, to make sure it links as you expect it to. The linking command will be at the bottom of the output. Thank you! This has helped and I linked my program. As it turned out dmd invoked gcc to link and it supplied my -ldl argument first! I copy-pasted

Binary Data Serialization Libraries

2013-12-06 Thread Jeroen Bollen
Are there any Binary Data Serialization Libraries available written in D2? I'm looking for something like a BSON read/write library. (Although can be any other binary language really)

Equality == comparisons with floating point numbers

2013-12-06 Thread Joseph Rushton Wakeling
A dangerous topic for everyone :-) I've been working with some unittests involving comparing the output of different but theoretically equivalent versions of the same calculation. To my surprise, calculations which I assumed would produce identical output, were failing equality tests. It

Re: Equality == comparisons with floating point numbers

2013-12-06 Thread Ali Çehreli
On 12/06/2013 05:47 AM, Joseph Rushton Wakeling wrote: I decided to check by writing out the whole floating-point numbers formatted with %.80f. This confirmed my suspicion that the numbers were indeed identical. Are they identical when printed with %a? Ali

Re: Equality == comparisons with floating point numbers

2013-12-06 Thread Joseph Rushton Wakeling
On 06/12/13 15:02, Ali Çehreli wrote: Are they identical when printed with %a? On my 64-bit Linux system, yes. I'll push an updated patch to test and see if the various 32-bit systems report similar results (I was getting failures on 32-bit Darwin, BSD and Linux). Thanks very much for the

Re: Binary Data Serialization Libraries

2013-12-06 Thread Dicebot
On Friday, 6 December 2013 at 13:33:45 UTC, Jeroen Bollen wrote: Are there any Binary Data Serialization Libraries available written in D2? I'm looking for something like a BSON read/write library. (Although can be any other binary language really) vibe.d BSON :

Re: Binary Data Serialization Libraries

2013-12-06 Thread Max Klyga
On 2013-12-06 13:33:44 +, Jeroen Bollen said: Are there any Binary Data Serialization Libraries available written in D2? I'm looking for something like a BSON read/write library. (Although can be any other binary language really) MessagePack - format very similar to BSON -

Re: Equality == comparisons with floating point numbers

2013-12-06 Thread Joseph Rushton Wakeling
On 06/12/13 15:02, Ali Çehreli wrote: Are they identical when printed with %a? Yes. You can see some of the results here (for the 32-bit systems where I was getting failures): https://d.puremagic.com/test-results/pull.ghtml?projectid=1runid=811923logid=6

Re: I/O related question, and ini parsing

2013-12-06 Thread Mineko
On Friday, 6 December 2013 at 05:32:56 UTC, Mineko wrote: On Friday, 6 December 2013 at 05:22:07 UTC, Ali Çehreli wrote: On 12/05/2013 08:43 PM, Mineko wrote: I might be missing out on some D-only features The first thing I've noticed is that you are not using UFCS, perhaps because you

Re: Unresolvable references to dlopen, dlclose etc

2013-12-06 Thread Jacob Carlborg
On 2013-12-06 14:25, Mafi wrote: Thank you! This has helped and I linked my program. As it turned out dmd invoked gcc to link and it supplied my -ldl argument first! I copy-pasted that command into a shell and moved the -ldl to the very end and it worked. How do instruct dmd to do the same? As

Re: I/O related question, and ini parsing

2013-12-06 Thread bearophile
Mineko: https://github.com/MinekoRox/Breaker-3D-Game-Engine Notes: - Usually in D imports are at the top (after module name and module ddoc). - Perhaps io.getDir is better written an a switch on strings. - I suggest to add the immutable/cost to every variable that doesn't need to mutate,

Re: Is this reasonable?

2013-12-06 Thread Steve Teale
On Thursday, 5 December 2013 at 17:15:39 UTC, Steve Teale wrote: Here I feel like a beginner, but it seems very unfriendly: import std.stdio; struct ABC { double a; int b; bool c; } ABC[20] aabc; void foo(int n) { writefln(n: %d, aabc.length: %d, n, aabc.length); if (n

Re: Is this reasonable?

2013-12-06 Thread monarch_dodra
On Thursday, 5 December 2013 at 18:26:48 UTC, Jonathan M Davis wrote: To be fair, you can't solve the problem automatically. It's fundamentally wrong to compare signed and unsigned values, and doing either the conversion to unsigned or to signed could be wrong (or both could be wrong),

Re: I/O related question, and ini parsing

2013-12-06 Thread Dicebot
On Friday, 6 December 2013 at 16:56:29 UTC, bearophile wrote: Mineko: https://github.com/MinekoRox/Breaker-3D-Game-Engine Notes: - Usually in D imports are at the top (after module name and module ddoc). I think it is a bad practice that should be discouraged. Moving as much imports as

Re: I/O related question, and ini parsing

2013-12-06 Thread bearophile
Dicebot: I think it is a bad practice that should be discouraged. Moving as much imports as possible into local scope has lot of practical benefits, primarily maintenance and compilation times. Right. I was referring to the global ones. Bye, bearophile

Re: Is this reasonable?

2013-12-06 Thread Jonathan M Davis
On Friday, December 06, 2013 18:28:09 monarch_dodra wrote: On Thursday, 5 December 2013 at 18:26:48 UTC, Jonathan M Davis wrote: To be fair, you can't solve the problem automatically. It's fundamentally wrong to compare signed and unsigned values, and doing either the conversion to

How to load a derelict program in D?

2013-12-06 Thread Jeroen Bollen
I am using the derelict-sfml2 package in my code. My code: import std.stdio; import derelict.sfml2.window; void main() { DerelictSFML2Window.load(); sfVideoMode videoMode = sfVideoMode(1280, 720); sfWindow* window = sfWindow_create(videoMode, Animation, sfNone, null); } For

how to find the type of a supplied variable

2013-12-06 Thread seany
I have the following void functionName(T)(T argumentVar) { /+ now i want that based on type of argumentVar, things will be done eg : if there is a function gettype; then : +/ switch(argumentVar.gettype) { case string array: //do something

Re: how to find the type of a supplied variable

2013-12-06 Thread H. S. Teoh
On Fri, Dec 06, 2013 at 09:18:51PM +0100, seany wrote: I have the following void functionName(T)(T argumentVar) { /+ now i want that based on type of argumentVar, things will be done eg : if there is a function gettype; then : +/ switch(argumentVar.gettype)

Re: stdout - autoflushing

2013-12-06 Thread Dejan Lekic
Benji wrote: Hello, in order to have correctly displayed output (before reading something from stdin), I must call stdout.flush(). Sometimes, it's really annoying, especially when it is necessarry to call it 10 times. For example: write(Enter some string: ); stdout.flush(); string a =

Re: how to find the type of a supplied variable

2013-12-06 Thread seany
why do i need the static? (is that not supposed to prevent insertations of new scopes inside the braces? is it really needed?)

Re: how to find the type of a supplied variable

2013-12-06 Thread Dicebot
On Friday, 6 December 2013 at 20:58:15 UTC, seany wrote: why do i need the static? (is that not supposed to prevent insertations of new scopes inside the braces? is it really needed?) You can possibly use normal if but most likely you will get compilation errors from other conditional

Re: stdout - autoflushing

2013-12-06 Thread Adam D. Ruppe
On Friday, 6 December 2013 at 20:39:22 UTC, Dejan Lekic wrote: Benji wrote: Is there any way to prevent this? I doubt. Your IDE is buffering application's streams. You know though, this happens often enough that maybe we should just throw in a stdout.flush to the global readln function. I

Re: how to find the type of a supplied variable

2013-12-06 Thread Jesse Phillips
On Friday, 6 December 2013 at 20:58:15 UTC, seany wrote: why do i need the static? (is that not supposed to prevent insertations of new scopes inside the braces? is it really needed?) 'static if' means check this at compile time, which happens to not introduce a new scope, because otherwise

Re: How to load a derelict program in D?

2013-12-06 Thread Kelet
On Friday, 6 December 2013 at 19:50:52 UTC, Jeroen Bollen wrote: I am using the derelict-sfml2 package in my code. My code: import std.stdio; import derelict.sfml2.window; void main() { DerelictSFML2Window.load(); sfVideoMode videoMode = sfVideoMode(1280, 720); sfWindow*

Re: how to compose delegate type

2013-12-06 Thread Ellery Newcomer
On 12/05/2013 09:33 PM, Jesse Phillips wrote: I don't think I understand what you mean: this code illustrates it: class Z { string a() immutable { return 1; } string b() { return 2; } } template F(t) { alias immutable(t) F; } alias typeof(Z.init.a)

Re: I/O related question, and ini parsing

2013-12-06 Thread Mineko
Alright cool, I'll get on that real soon, I'm not too used to D's importing system anyway, so I appreciate it. I suppose I'll have to do some research on pure and nothrow too, I've never really bothered with those.

Re: How to load a derelict program in D?

2013-12-06 Thread Mike Parker
On Friday, 6 December 2013 at 19:50:52 UTC, Jeroen Bollen wrote: I am using the derelict-sfml2 package in my code. My code: import std.stdio; import derelict.sfml2.window; void main() { DerelictSFML2Window.load(); sfVideoMode videoMode = sfVideoMode(1280, 720); sfWindow*