Re: Equality == comparisons with floating point numbers

2013-12-07 Thread Abdulhaq
On Friday, 6 December 2013 at 14:58:31 UTC, Joseph Rushton Wakeling wrote: 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):

Re: Equality == comparisons with floating point numbers

2013-12-07 Thread John Colvin
On Friday, 6 December 2013 at 13:47:12 UTC, Joseph Rushton Wakeling wrote: 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

Re: Equality == comparisons with floating point numbers

2013-12-07 Thread Joseph Rushton Wakeling
On 07/12/13 09:29, Abdulhaq wrote: Some time ago in a test I had written (C++) apparently identical floating point operations were returning different answers (in the 17th/18th sign fig), when re-running the same code with the same data. The paper described how the result could change if the

Re: I/O related question, and ini parsing

2013-12-07 Thread nazriel
On Friday, 6 December 2013 at 04:43:44 UTC, Mineko wrote: So, it's my first time implementing something like logging and ini parsing/creating, and it appears to work perfectly, but I'm not neccessarily a master of D yet.. So, I wanted some advice from my seniors if there's anything I should

Re: regading detection of stdin

2013-12-07 Thread Hugo Florentino
On Fri, 06 Dec 2013 06:42:01 +0100, Jesse Phillips wrote: On Friday, 6 December 2013 at 02:41:28 UTC, Hugo Florentino wrote: I see... so the problem simply was that function readln was expecting user input. In that case, this is not what I intended. I want the application to receive the

Help Finding Strange Memory Bug (Code linked to C library)

2013-12-07 Thread Craig Dillabaugh
Hello, I recently wrote bindings to the C-library Shapelib (it reads/writes a common file format used in Geographic Information Systems). I've been trying to write a small test program to make sure my bindings 'work' and I've come across a bizarre memory bug. I THINK I've identified the

iterate over enum name:value pairs

2013-12-07 Thread Jay Norwood
In Ali Çehreli very nice book there is this example of iterating over enum range which, as he notes, fails http://ddili.org/ders/d.en/enum.html enum Suit { spades, hearts, diamonds, clubs } foreach (suit; Suit.min .. Suit.max) { writefln(%s: %d, suit, suit); } spades: 0

Re: iterate over enum name:value pairs

2013-12-07 Thread bearophile
Jay Norwood: In Ali Çehreli very nice book there is this example of iterating over enum range which, as he notes, fails http://ddili.org/ders/d.en/enum.html enum Suit { spades, hearts, diamonds, clubs } foreach (suit; Suit.min .. Suit.max) { writefln(%s: %d, suit, suit); }

Threading methodology

2013-12-07 Thread Frustrated
I have to process n arrays in some partial order. Instead of all working only on the n arrays and reusing them, if I duplicate them(effectively write once read many) does that make things simpler and allow threading to be used more efficiently? Basically, instead of having to worry about

Re: I/O related question, and ini parsing

2013-12-07 Thread Mineko
On Saturday, 7 December 2013 at 12:23:38 UTC, nazriel wrote: On Friday, 6 December 2013 at 04:43:44 UTC, Mineko wrote: So, it's my first time implementing something like logging and ini parsing/creating, and it appears to work perfectly, but I'm not neccessarily a master of D yet.. So, I

Re: I/O related question, and ini parsing

2013-12-07 Thread Mineko
On Saturday, 7 December 2013 at 12:23:38 UTC, nazriel wrote: imports are private by default. Also I noticed few overlaping private declarations, for example here: https://github.com/MinekoRox/Breaker-3D-Game-Engine/blob/master/src/breaker/utility/belt.d#L54 Sorry for the double post, this

Re: how to compose delegate type

2013-12-07 Thread Jesse Phillips
On Saturday, 7 December 2013 at 01:18:06 UTC, Ellery Newcomer wrote: 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; } }

Re: I/O related question, and ini parsing

2013-12-07 Thread Gary Willoughby
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

is there anything like a DUB manual?

2013-12-07 Thread Fra
I finally decided to try out DUB. The simple examples work great, but I could not find any user guide/list of possible options to be put in the package.json file. Just as an example, how do you pass specific compiler flags like '-J'?

Re: is there anything like a DUB manual?

2013-12-07 Thread Nicolas Sicard
On Saturday, 7 December 2013 at 19:59:50 UTC, Fra wrote: I finally decided to try out DUB. The simple examples work great, but I could not find any user guide/list of possible options to be put in the package.json file. Just as an example, how do you pass specific compiler flags like '-J'?

Shared library: loading doesn't call shared static this

2013-12-07 Thread Mathias LANG
Hello, I'm in the process of creating a PAM module using D. First step, I ported pam/modules.h and the included pam/_types.h to D, pretty straightforward. Then I created a simple D source, which looks like: extern(C) int pam_sm_open_session(pam_handle_t* pamh, int flags, int ac, const

Re: Shared library: loading doesn't call shared static this

2013-12-07 Thread yazd
On Saturday, 7 December 2013 at 20:11:15 UTC, Mathias LANG wrote: Hello, I'm in the process of creating a PAM module using D. First step, I ported pam/modules.h and the included pam/_types.h to D, pretty straightforward. Then I created a simple D source, which looks like: extern(C) int

Re: is there anything like a DUB manual?

2013-12-07 Thread Fra
On Saturday, 7 December 2013 at 20:13:52 UTC, Nicolas Sicard wrote: Did you have a look at http://code.dlang.org/package-format ? how the hell did I managed to miss that? :D Thankee

Re: regading detection of stdin

2013-12-07 Thread Adam D. Ruppe
Sounds like what you need is to see if stdin is a tty. import core.sys.posix.unistd; // has isatty() void main() { import std.stdio; writeln(isatty(0)); // 0 is stdin, so this will show 1 if keyboard or 0 if pope }

Re: Unresolvable references to dlopen, dlclose etc

2013-12-07 Thread Mafi
On Friday, 6 December 2013 at 16:54:14 UTC, Jacob Carlborg wrote: 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

Re: regading detection of stdin

2013-12-07 Thread Chris Cain
On Friday, 6 December 2013 at 00:24:22 UTC, Hugo Florentino wrote: Hi, I was trying to do something like this (using dmd.2.064.2 both from Windows and Linux), but if nothing is passed from stdin and no parameter is provided, the application freezes: ...snip... Where is the problem?

Re: Equality == comparisons with floating point numbers

2013-12-07 Thread Joseph Rushton Wakeling
On 07/12/13 12:08, Joseph Rushton Wakeling wrote: On 07/12/13 09:29, Abdulhaq wrote: Some time ago in a test I had written (C++) apparently identical floating point operations were returning different answers (in the 17th/18th sign fig), when re-running the same code with the same data. The

File Picker

2013-12-07 Thread Malkierian
Is there anything in D that currently brings up a window to find and choose a file, or am I going to have to make it myself? Isn't there a built-in something or other I can hook into in Windows?

Re: Shared library: loading doesn't call shared static this

2013-12-07 Thread Ellery Newcomer
On Saturday, 7 December 2013 at 20:11:15 UTC, Mathias LANG wrote: afaik, druntime does not officially support the C main, D shared library use case yet. If you have only 1 D shared library, you can insert calls to rt_init and rt_term into shared lib constructors/dtors with gcc. This has

Re: how to compose delegate type

2013-12-07 Thread Ellery Newcomer
On Saturday, 7 December 2013 at 19:36:50 UTC, Jesse Phillips wrote: This declaration doesn't make sense to me: string a() immutable { return 1; } http://dlang.org/class.html#member-functions

Re: Help Finding Strange Memory Bug (Code linked to C library)

2013-12-07 Thread Rémy Mouëza
My strategy here would be to: A. run the program in a debugger, say GDB, to get a exhaustive stacktrace for hints about where to look at. B. have a quick look at the library directly (the Use the Source Luke strategy). Since I was curious about your problem (you had everything correct -

Re: File Picker

2013-12-07 Thread Adam D. Ruppe
On Saturday, 7 December 2013 at 23:00:00 UTC, Malkierian wrote: Is there anything in D that currently brings up a window to find and choose a file, or am I going to have to make it myself? Isn't there a built-in something or other I can hook into in Windows? Yeah, on Windows, you can just

Re: Help Finding Strange Memory Bug (Code linked to C library)

2013-12-07 Thread Ali Çehreli
On 12/07/2013 03:11 PM, Rémy Mouëza wrote: the last pointer, `double * padfMaxBound` is actually a pointer to an array of 4 elements: Great sleuthing! :) This thread is a good example of C's Biggest Mistake: http://www.drdobbs.com/architecture-and-design/cs-biggest-mistake/228701625 Ali

Re: how to compose delegate type

2013-12-07 Thread Jesse Phillips
On Saturday, 7 December 2013 at 23:02:18 UTC, Ellery Newcomer wrote: On Saturday, 7 December 2013 at 19:36:50 UTC, Jesse Phillips wrote: This declaration doesn't make sense to me: string a() immutable { return 1; } http://dlang.org/class.html#member-functions That isn't

Re: Digitalmars-d-learn Digest, Vol 95, Issue 30

2013-12-07 Thread Hugo Florentino
On Sat, 07 Dec 2013 23:03:10 +0100 Chris Cain wrote: On Friday, 6 December 2013 at 00:24:22 UTC, Hugo Florentino wrote: Hi, I was trying to do something like this (using dmd.2.064.2 both from Windows and Linux), but if nothing is passed from stdin and no parameter is provided, the application

Re: regading detection of stdin

2013-12-07 Thread Hugo Florentino
On Sat, 07 Dec 2013 21:33:56 +0100, Adam D. Ruppe wrote: Sounds like what you need is to see if stdin is a tty. import core.sys.posix.unistd; // has isatty() void main() { import std.stdio; writeln(isatty(0)); // 0 is stdin, so this will show 1 if keyboard or 0 if pope }

Re: regading detection of stdin

2013-12-07 Thread Adam D. Ruppe
On Sunday, 8 December 2013 at 02:11:01 UTC, Hugo Florentino wrote: Interesting, thanks for pointing that (this function is not described at all in the source code) Yeah, it is a standard unix function so D itself doesn't document it, but you can run man isatty in Linux or search for isatty

Re: iterate over enum name:value pairs

2013-12-07 Thread Jay Norwood
Thanks. This is exactly what I was looking for. I tried this iteration below, based on the example shown in the std.traits documentation, and the int values are not what I expected, but your example works fine. http://dlang.org/phobos/std_traits.html#.EnumMembers import std.traits; void