Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 04:06:23 UTC, Samwise wrote: On Wednesday, 18 January 2017 at 03:51:50 UTC, ketmar wrote: On Wednesday, 18 January 2017 at 03:37:46 UTC, Samwise wrote: extern int getReturnCode() { return 4; } still does not compile using the command from above. I may

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 04:06:23 UTC, Samwise wrote: I have both the header in hello.d and the actual function in getReturnCode.d as extern, and it still fails with the same error. nope. it works.

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:51:50 UTC, ketmar wrote: On Wednesday, 18 January 2017 at 03:37:46 UTC, Samwise wrote: extern int getReturnCode() { return 4; } still does not compile using the command from above. I may very well be misunderstanding you though. yep. *both* prototy

Re: Printing a floats in maximum precision

2017-01-17 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 00:09:42 UTC, Nordlöw wrote: What's the easiest way to print a double in maximum precision? %.6g for floats and %.17g for doubles. This is for example what's used on std.json to get a perfect conversion from string to value. the number is the maximum number of

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:37:46 UTC, Samwise wrote: extern int getReturnCode() { return 4; } still does not compile using the command from above. I may very well be misunderstanding you though. yep. *both* prototype and real declaration should be `extern(C)`. `(C)` part is

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:25:47 UTC, Stefan Koch wrote: On Wednesday, 18 January 2017 at 03:11:08 UTC, Samwise wrote: On Wednesday, 18 January 2017 at 02:48:45 UTC, James Buren wrote: Import the source file containing the external function instead of writing that prototype. It should

Re: Printing a floats in maximum precision

2017-01-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 00:23:37 UTC, pineapple wrote: On Wednesday, 18 January 2017 at 00:09:42 UTC, Nordlöw wrote: What's the easiest way to print a double in maximum precision? https://github.com/pineapplemachine/mach.d/blob/master/mach/text/numeric/floats.d#L60 You can also try t

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:11:08 UTC, Samwise wrote: On Wednesday, 18 January 2017 at 02:48:45 UTC, James Buren wrote: Import the source file containing the external function instead of writing that prototype. It should compile then. This seems like a workaround more than a permanent

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 02:48:45 UTC, James Buren wrote: Import the source file containing the external function instead of writing that prototype. It should compile then. This seems like a workaround more than a permanent solution. It would work, but still. I'm also not sure about th

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread James Buren via Digitalmars-d-learn
Import the source file containing the external function instead of writing that prototype. It should compile then.

DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Samwise via Digitalmars-d-learn
Alright. For the sake of this argument, I'm going to post all the stuff about a really tiny boring program that quite literally does nothing, even though I found this issue when I was working with a much larger project with more functions. Basically I'm getting errors when I attempt to compile

Re: iterating through members of bitfields

2017-01-17 Thread Ali Çehreli via Digitalmars-d-learn
On 01/17/2017 04:37 PM, Nestor wrote: Hi, I was just looking at an interesting function from http://codepad.org/lSDTFd7E : void printFields(T)(T args) { auto values = args.tupleof; size_t max; size_t temp; foreach (index, value; values) { temp = T.tupleof[index].stringof.length;

iterating through members of bitfields

2017-01-17 Thread Nestor via Digitalmars-d-learn
Hi, I was just looking at an interesting function from http://codepad.org/lSDTFd7E : void printFields(T)(T args) { auto values = args.tupleof; size_t max; size_t temp; foreach (index, value; values) { temp = T.tupleof[index].stringof.length; if (max < temp) max = temp; } m

Re: Printing a floats in maximum precision

2017-01-17 Thread pineapple via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 00:09:42 UTC, Nordlöw wrote: What's the easiest way to print a double in maximum precision? https://github.com/pineapplemachine/mach.d/blob/master/mach/text/numeric/floats.d#L60 You can also try the formatting directive "%.20f" but unlike the former I can't of

Printing a floats in maximum precision

2017-01-17 Thread Nordlöw via Digitalmars-d-learn
What's the easiest way to print a double in maximum precision?

Re: Where is floating point next{Up,Down}?

2017-01-17 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 23:38:46 UTC, Ali Çehreli wrote: Found'em! :) https://dlang.org/phobos/std_math.html#.nextUp Thanks!

Re: Where is floating point next{Up,Down}?

2017-01-17 Thread Ali Çehreli via Digitalmars-d-learn
On 01/17/2017 03:30 PM, Nordlöw wrote: I can't find nextUp(x) and nextDown(x) described in https://dlang.org/d-floating-point.html Are these D1 only? Is there anything like it in D2/Phobos? Found'em! :) https://dlang.org/phobos/std_math.html#.nextUp Ali

Where is floating point next{Up,Down}?

2017-01-17 Thread Nordlöw via Digitalmars-d-learn
I can't find nextUp(x) and nextDown(x) described in https://dlang.org/d-floating-point.html Are these D1 only? Is there anything like it in D2/Phobos?

Re: Quine using strings?

2017-01-17 Thread Jesse Phillips via Digitalmars-d-learn
On Monday, 16 January 2017 at 13:11:38 UTC, pineapple wrote: On Monday, 16 January 2017 at 09:33:23 UTC, Nestor wrote: PS. Isn't this approach considered "cheating" in quines? ;) I'm afraid so - while the empty program has been technically accepted as being a quine (e.g. http://www.ioccc.org

Re: C++-style mutable members

2017-01-17 Thread Namespace via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 20:21:34 UTC, Nordlöw wrote: Is there a way to mimic C++-style `mutable` members in D? You could store a ptr to the member outside: import std.stdio; private int* _pid; struct A { int id; this(int id) { this

Re: C++-style mutable members

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 20:50:34 UTC, Nordlöw wrote: On Tuesday, 17 January 2017 at 20:47:35 UTC, ketmar wrote: Is there a way to mimic C++-style `mutable` members in D? sure: don't use `const`. otherwise — no, there is simply no way to «mimic» 'em due to completely different meaning of

Re: C++-style mutable members

2017-01-17 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 20:47:35 UTC, ketmar wrote: Is there a way to mimic C++-style `mutable` members in D? sure: don't use `const`. otherwise — no, there is simply no way to «mimic» 'em due to completely different meaning of `const` in D and C++. I'm aware of the difference. I'm jus

Re: C++-style mutable members

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 20:21:34 UTC, Nordlöw wrote: Is there a way to mimic C++-style `mutable` members in D? sure: don't use `const`. otherwise — no, there is simply no way to «mimic» 'em due to completely different meaning of `const` in D and C++.

C++-style mutable members

2017-01-17 Thread Nordlöw via Digitalmars-d-learn
Is there a way to mimic C++-style `mutable` members in D?

Re: Gtkd how to filter TreeView according to user input

2017-01-17 Thread Erdem via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 19:07:21 UTC, Ali Çehreli wrote: On 01/17/2017 01:25 AM, Erdem wrote: > void main(string[] args) > { > Main.init(args); > new MyWindow(); > Main.run(); > } I have no experience with Gtkd but the code inside main looks fundamentally wrong. One would ex

Re: Gtkd how to filter TreeView according to user input

2017-01-17 Thread Ali Çehreli via Digitalmars-d-learn
On 01/17/2017 01:25 AM, Erdem wrote: > void main(string[] args) > { > Main.init(args); > new MyWindow(); > Main.run(); > } I have no experience with Gtkd but the code inside main looks fundamentally wrong. One would expect you to do something with the MyWindow object: auto w

Re: Initializing floating point types with explicit mantisa and exponent

2017-01-17 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 18:25:46 UTC, kinke wrote: It should and I looked into that as well, but I didn't like the implementation as loop: https://github.com/dlang/phobos/blob/master/std/math.d#L5988 A special case for base x == 2 wouldn't hurt. That seems strange. Why isn't that a bu

Re: Initializing floating point types with explicit mantisa and exponent

2017-01-17 Thread kinke via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 17:56:13 UTC, Nordlöw wrote: On Tuesday, 17 January 2017 at 16:40:57 UTC, kinke wrote: If it doesn't have to be D ;), it can be as simple as `core.stdc.math.ldexp(1, exponent)`. No CTFE though. Isn't it a simple as 2.0^^exponent ? It should and I looked i

Re: Initializing floating point types with explicit mantisa and exponent

2017-01-17 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 16:40:57 UTC, kinke wrote: If it doesn't have to be D ;), it can be as simple as `core.stdc.math.ldexp(1, exponent)`. No CTFE though. Isn't it a simple as 2.0^^exponent ?

Re: Initializing floating point types with explicit mantisa and exponent

2017-01-17 Thread kinke via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 00:08:24 UTC, Nordlöw wrote: How do I best initialize a D double to an exact mantissa and exponent representation? I'm specifically interested in 2^^i for all i in [min_exp, max_exp] If it doesn't have to be D ;), it can be as simple as `core.stdc.math.lde

Re: Thread will get garbage collected?

2017-01-17 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 08:58:33 UTC, Arun Chandrasekaran wrote: Interesting. Why doesn't the thread get GC'd in this case even without any reference still active? There will be a reference to it in druntime itself: http://dlang.org/phobos/core_thread.html#.Thread.getThis

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-17 Thread Nestor via Digitalmars-d-learn
On Monday, 16 January 2017 at 14:47:23 UTC, Era Scarecrow wrote: On Sunday, 15 January 2017 at 19:48:04 UTC, Nestor wrote: I see. So correcting my original doubt: How could I parse an UTF16LE file line by line (producing a proper string in each iteration) without loading the entire file into

Re: How can I implement this in D: a variant array of varying function pointer types (diff number of args or types)

2017-01-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 10:49:14 UTC, Enjoys Math wrote: Z add(Z...)(Z a...) { return a + b; } func[] operatorPool = [&add!int]; Variant library isn't liking that. Removing & causes another error. Essentially I want a pool of all operators that I define, but these operators

Re: How can I implement this in D: a variant array of varying function pointer types (diff number of args or types)

2017-01-17 Thread Enjoys Math via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 10:49:14 UTC, Enjoys Math wrote: Z add(Z...)(Z a...) { return a + b; } func[] operatorPool = [&add!int]; Variant library isn't liking that. Removing & causes another error. Essentially I want a pool of all operators that I define, but these operators

How can I implement this in D: a variant array of varying function pointer types (diff number of args or types)

2017-01-17 Thread Enjoys Math via Digitalmars-d-learn
Z add(Z...)(Z a...) { return a + b; } func[] operatorPool = [&add!int]; Variant library isn't liking that. Removing & causes another error. Essentially I want a pool of all operators that I define, but these operators can be of differing types (which I should be able to programatic

Re: Thread will get garbage collected?

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 08:58:33 UTC, Arun Chandrasekaran wrote: Interesting. Why doesn't the thread get GC'd in this case even without any reference still active? basically 'cause there is no reliable way to correctly "abort" a thread. nobody knows what is really going on inside it, so

Gtkd how to filter TreeView according to user input

2017-01-17 Thread Erdem via Digitalmars-d-learn
I'd like to filter Treeview data according to user input. How should I do that? When I run this program it gives segmentation fault error. import gtk.Main; import gtk.MainWindow; import gtk.Box; import gtk.Entry; import gtk.EditableIF; import gtk.TreeModelFilter; import gtk.TreeView; import gtk

Re: Thread will get garbage collected?

2017-01-17 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 08:12:50 UTC, ketmar wrote: import core.thread; import core.time; import std.stdio; void threadStarter (string path) { new Thread({ for (;;) { writeln(path); Thread.sleep(1.seconds); } }).start(); } class A { ~this () { import core.stdc.

Re: Thread will get garbage collected?

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 07:53:32 UTC, thedeemon wrote: On Monday, 16 January 2017 at 22:08:56 UTC, JN wrote: Am I correctly understanding, that after going out of scope, it's possible for GC to destroy my thread before the file finishes loading? How to prevent GC from destroying my thre

Re: Thread will get garbage collected?

2017-01-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 16 January 2017 at 22:08:56 UTC, JN wrote: Am I correctly understanding, that after going out of scope, it's possible for GC to destroy my thread before the file finishes loading? How to prevent GC from destroying my thread before it finishes and make sure the file is loaded complet