Optimising JSON parsing leads to wierd execution timings

2017-03-25 Thread xtreak via Digitalmars-d-learn
Hi, Sorry for the double post. I have asked a question at Stackoverflow regarding this : https://stackoverflow.com/questions/42992507/get-float-value-out-of-jsonvalue-in-dlang . I have a `rating` field that might have 3 which parses to JSONValue.integer or 3.4 which parses to

Re: Exporting template function instances to C

2017-03-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 25 March 2017 at 02:21:33 UTC, data pulverizer wrote: Thanks a lot ... I was half joking playing with the name "mangling" but I appreciate your explanations and suggestions. This is the internet, I can't tell if you're a newb or sarcastic, and given this is a learn forum I'm

Re: Exporting template function instances to C

2017-03-25 Thread data pulverizer via Digitalmars-d-learn
On Saturday, 25 March 2017 at 06:17:15 UTC, Nicholas Wilson wrote: On Saturday, 25 March 2017 at 02:21:33 UTC, data pulverizer wrote: Thanks a lot ... I was half joking playing with the name "mangling" but I appreciate your explanations and suggestions. This is the internet, I can't tell if

Re: 'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread NotSpooky via Digitalmars-d-learn
On Saturday, 25 March 2017 at 15:52:15 UTC, crimaniak wrote: Simple File test: void main() { import std.stdio; File f = File("test.txt", "w"); f.writeln("hello"); } All works as expected. Now let's add __gshared: void main() { import

Re: 'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread crimaniak via Digitalmars-d-learn
On Saturday, 25 March 2017 at 16:08:49 UTC, NotSpooky wrote: __gshared implies static,... Thanks! Confusing for me moment.

'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread crimaniak via Digitalmars-d-learn
Simple File test: void main() { import std.stdio; File f = File("test.txt", "w"); f.writeln("hello"); } All works as expected. Now let's add __gshared: void main() { import std.stdio; __gshared File f = File("test.txt", "w");

Re: recommend Git GUI client for Linux?

2017-03-25 Thread XavierAP via Digitalmars-d-learn
On Thursday, 2 March 2017 at 06:16:09 UTC, Patrick Schluter wrote: Here [1] is the official git page listing all GUI clients for different plartforms. I use GitExtensions[2] and I like it a lot. It works very well and all the complicated stuff can be done from the GUI interface and also from

Re: 'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread StarGrazer via Digitalmars-d-learn
On Saturday, 25 March 2017 at 16:46:00 UTC, crimaniak wrote: On Saturday, 25 March 2017 at 16:08:49 UTC, NotSpooky wrote: __gshared implies static,... Thanks! Confusing for me moment. try this: import std.stdio; void main() { import std.stdio; __gshared File f;

Re: Howto catch SocketOSException?

2017-03-25 Thread bauss via Digitalmars-d-learn
On Sunday, 26 March 2017 at 00:34:03 UTC, Jolly James wrote: How do you catch an std.socket.SocketOSException? The following does not work, as the exception occurs anyway and leads to a crash: import ae.net.asockets; void main(string[] args) { TcpServer tcp = new TcpServer();

Re: Howto catch SocketOSException?

2017-03-25 Thread Jolly James via Digitalmars-d-learn
On Sunday, 26 March 2017 at 01:22:24 UTC, bauss wrote: On Sunday, 26 March 2017 at 00:34:03 UTC, Jolly James wrote: [...] This part: catch (std.socket.SocketOSException e) [...] [...] I know that inheritance stuff, but none (!) of them catches that strange exception either. You can

Re: Howto catch SocketOSException?

2017-03-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 26 March 2017 at 02:24:56 UTC, Jolly James wrote: You can ignore the loop()-method. It is not called as the application will never reach this statement, because it cannot, because it crashes already in the listen()-method in consequence of the exception that does not get caught by

Re: union.sizeof

2017-03-25 Thread ag0aep6g via Digitalmars-d-learn
On 03/25/2017 11:37 PM, zabruk70 wrote: union Union1 { align(1): byte[5] bytes5; struct { align(1): char char1; uint int1; } } void main () { import std.stdio: writefln; writefln("Union1.sizeof=%d", Union1.sizeof); //prints 8, not 5 } I'm not sure how the align

Re: union.sizeof

2017-03-25 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: //DMD 2.073.1 and latest 2.075.0-master-972eaed //Windows 7 32-bit union Union1 { align(1): byte[5] bytes5; struct { align(1): char char1; uint int1; } } void main () { import std.stdio: writefln; writefln("Union1.sizeof=%d", Union1.sizeof);

Re: union.sizeof

2017-03-25 Thread zabruk70 via Digitalmars-d-learn
Thank you ag0aep6g and ketmar!! I will use additional outside align. I want packing inside, you are right. But i check result size with assert() and failed. But for clearness... I was thinked, that align not changes SIZE, but changes LOCATION. I was thinked, that "align(X) union Union1" just

Re: union.sizeof

2017-03-25 Thread kinke via Digitalmars-d-learn
On Saturday, 25 March 2017 at 22:45:22 UTC, ketmar wrote: zabruk70 wrote: //DMD 2.073.1 and latest 2.075.0-master-972eaed //Windows 7 32-bit union Union1 { align(1): byte[5] bytes5; struct { align(1): char char1; uint int1; } } void main () { import

Howto catch SocketOSException?

2017-03-25 Thread Jolly James via Digitalmars-d-learn
How do you catch an std.socket.SocketOSException? The following does not work, as the exception occurs anyway and leads to a crash: import ae.net.asockets; void main(string[] args) { TcpServer tcp = new TcpServer(); try { tcp.listen(2345,

union.sizeof

2017-03-25 Thread zabruk70 via Digitalmars-d-learn
//DMD 2.073.1 and latest 2.075.0-master-972eaed //Windows 7 32-bit union Union1 { align(1): byte[5] bytes5; struct { align(1): char char1; uint int1; } } void main () { import std.stdio: writefln; writefln("Union1.sizeof=%d", Union1.sizeof); //prints 8, not 5 } I

Re: union.sizeof

2017-03-25 Thread kinke via Digitalmars-d-learn
On Saturday, 25 March 2017 at 22:54:30 UTC, zabruk70 wrote: But for clearness... I was thinked, that align not changes SIZE, but changes LOCATION. I was thinked, that "align(X) union Union1" just force compiler to place Union1 on boundaries of X bytes... In order for all Union1 instances in

Re: union.sizeof

2017-03-25 Thread bauss via Digitalmars-d-learn
On Saturday, 25 March 2017 at 23:36:07 UTC, kinke wrote: On Saturday, 25 March 2017 at 22:45:22 UTC, ketmar wrote: zabruk70 wrote: [...] `align(1) union Union1` will do the trick. what you did is members packing. but the union itself is padded to integer size too. i.e. internal `align`

Re: union.sizeof

2017-03-25 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: Thank you ag0aep6g and ketmar!! I will use additional outside align. I want packing inside, you are right. But i check result size with assert() and failed. But for clearness... I was thinked, that align not changes SIZE, but changes LOCATION. I was thinked, that "align(X)