Re: strange static assert failure

2017-07-02 Thread Basile B. via Digitalmars-d-learn
On Sunday, 2 July 2017 at 08:55:42 UTC, Basile B. wrote: The second assert fails. Do you know why ? pass your way, i've forgot the typeof()... everything is okay actually.

Re: D and .lib files. C++/Other?

2017-07-02 Thread Damien Gibson via Digitalmars-d-learn
Ahh, you need to initialise the D runtime before you call any functions that depend on it (e.g. ones that interact with the file system). declare extern "C" int rt_init(); in your c++ code and call it before ConsoleWrite and it should work. Honestly i did try this and it didnt correct

strange static assert failure

2017-07-02 Thread Basile B. via Digitalmars-d-learn
I played with some strange stuff that are allowed, i.e "super" and "this" as BasicType, when I've reached this: class B { super ringuard(){return null;} void foo() { auto crate = ringuard(); pragma(msg, typeof(crate)); static assert(typeof(crate).stringof ==

Re: D and .lib files. C++/Other?

2017-07-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-01 21:11, Damien Gibson wrote: As well I only intended to use shared libraries not static ones... Well, you can use shared libraries in two different way, dynamic linking or dynamic loading. Dynamic linking is when you declare your external symbols as usual and you link with

Re: weird error message

2017-07-02 Thread drug via Digitalmars-d-learn
02.07.2017 04:06, Ali Çehreli пишет: On 07/01/2017 04:56 PM, crimaniak wrote: > about very long error messages generated in some > cases. Please submit a bug report. The compiler may be able to abbreviate certain types. For example, in this case most of the error message text is values of

Re: std.string.format call from varyargs

2017-07-02 Thread drug via Digitalmars-d-learn
02.07.2017 09:52, H. S. Teoh via Digitalmars-d-learn пишет: On Sun, Jul 02, 2017 at 12:49:30AM +, LeqxLeqx via Digitalmars-d-learn wrote: Hello! How does one go about invoking a templated-variatic function such as std.string.format with an array of objects? For example: string

std.json cannot read an array floats back from file

2017-07-02 Thread Yuri via Digitalmars-d-learn
Hi there, consider the following simple use case: import std.json; float[] floats = [1,2,3]; JSONValue j = "{}".parseJSON; j.object["floats"] = floats; std.file.write("test.json", j.toString); JSONValue jj = readText("test.json").parseJSON;

Re: std.string.format call from varyargs

2017-07-02 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jul 02, 2017 at 11:38:34AM +0300, drug via Digitalmars-d-learn wrote: > 02.07.2017 09:52, H. S. Teoh via Digitalmars-d-learn пишет: [...] > > Take a look at the docs that describe the "%(...%)" nested format > > specifiers. For example: > > > > int[] arr = [ 1, 2, 3 ]; > >

Re: std.json cannot read an array floats back from file

2017-07-02 Thread ketmar via Digitalmars-d-learn
Yuri wrote: Hi there, consider the following simple use case: import std.json; float[] floats = [1,2,3]; JSONValue j = "{}".parseJSON; j.object["floats"] = floats; std.file.write("test.json", j.toString); JSONValue jj = readText("test.json").parseJSON;

Funny issue with casting double to ulong

2017-07-02 Thread Saurabh Das via Digitalmars-d-learn
Consider this snippet: void main() { import std.stdio; auto a = 6.2151; auto b = a * 1; auto c = cast(ulong)b; writeln("a: ", typeof(a).stringof, " ", a); writeln("b: ", typeof(b).stringof, " ", b); writeln("c: ", typeof(c).stringof, " ", c); auto x =

Re: Funny issue with casting double to ulong

2017-07-02 Thread Basile B via Digitalmars-d-learn
On Monday, 3 July 2017 at 03:50:14 UTC, Saurabh Das wrote: Consider this snippet: void main() { import std.stdio; auto a = 6.2151; auto b = a * 1; auto c = cast(ulong)b; writeln("a: ", typeof(a).stringof, " ", a); writeln("b: ", typeof(b).stringof, " ", b);

Re: Funny issue with casting double to ulong

2017-07-02 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: On Monday, 3 July 2017 at 03:50:14 UTC, Saurabh Das wrote: [...] 6.251 has no perfect double representation. It's real value is: 6.215099962483343551867E0 Hence when you cast to ulong after the product by 10_000, this is

Re: Bulk allocation and partial deallocation for tree data structures.

2017-07-02 Thread Filip Bystricky via Digitalmars-d-learn
Anyone?

Re: Bulk allocation and partial deallocation for tree data structures.

2017-07-02 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 3 July 2017 at 02:51:49 UTC, Filip Bystricky wrote: Anyone? The answer is no. Partial deallocation in an arbitrary fashion is not advisable. And there are no standard library mechanisms for it.

Re: Funny issue with casting double to ulong

2017-07-02 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: 6.251 has no perfect double representation. It's real value is: I almost wonder if a BCD, fixed length or alternative for floating point should be an option... Either library, or a hook to change how the FPU works since doubles are

Re: std.json cannot read an array floats back from file

2017-07-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 2 July 2017 at 21:07:40 UTC, Yuri wrote: It is expected to print '2' in the console, however an exception is thrown: std.json.JSONException@/build/ldc-I3nwWj/ldc-0.17.1/runtime/phobos/std/json.d(235): JSONValue is not a floating type I think it just read the json string of "1"

Re: D and .lib files. C++/Other?

2017-07-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 2 July 2017 at 05:33:45 UTC, Damien Gibson wrote: K im retarded... So I forgot the golden rule, debug libs with debug app, release libs with release app.. I attempted loading the debug version of dll with D again just to see what kinda errors (may) come up there, sure enough there

Re: std.string.format call from varyargs

2017-07-02 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jul 02, 2017 at 12:49:30AM +, LeqxLeqx via Digitalmars-d-learn wrote: > Hello! > > How does one go about invoking a templated-variatic function such as > std.string.format with an array of objects? > > For example: > > string stringMyThing (string formatForMyThings, MyThing[]