Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-28 Thread sarn via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 07:41:36 UTC, Christian Köstlin wrote: As I understand the only difference between assert and enforce is, that assert is not compiled into releases? Thanks! Christian Pretty much so. The intention is that assert means something that's supposed to be true

Re: foreach for string[string]AA

2017-02-28 Thread ikod via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 15:15:00 UTC, Anton Pastukhov wrote: I can't see the logic in AA foreach order. Consider this code: ``` void main() { string[string] test = [ "one": "1", "two": "2", "three": "3", "four": "4" ]; import

foreach for string[string]AA

2017-02-28 Thread Anton Pastukhov via Digitalmars-d-learn
I can't see the logic in AA foreach order. Consider this code: ``` void main() { string[string] test = [ "one": "1", "two": "2", "three": "3", "four": "4" ]; import std.stdio:writeln; foreach(k, v; test) { writeln(k); } } Output:

Re: foreach for string[string]AA

2017-02-28 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 15:33:46 UTC, ikod wrote: AA implemented as hash table, so it doesn't preserve insertion order. You have to sort keys when you need: import std.algorithm; import std.stdio; void main() { auto aa = ["one":1, "two":2

Re: Calling destroy on struct pointer

2017-02-28 Thread Radu via Digitalmars-d-learn
On Saturday, 25 February 2017 at 16:39:18 UTC, Moritz Maxeiner wrote: On Saturday, 25 February 2017 at 15:13:27 UTC, Radu wrote: [...] Thanks for the example. [...] Hm, that's an issue you'd best take up to the bugtracker, I think. Maybe there's a way around that, but I don't know.

Building a project with CMAKE

2017-02-28 Thread berni via Digitalmars-d-learn
I'm using CMAKE to build my project. With https://github.com/dcarp/cmake-d this works almost. The only thing I do not manage to get working is running cmake in release mode. When I use -DCMAKE_BUILD_TYPE=Release I get some linker errors, which I do not get, when compiling manually. (In both

Re: foreach for string[string]AA

2017-02-28 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 28 Feb 2017 15:15:00 + Anton Pastukhov via Digitalmars-d-learn napsáno: > I can't see the logic in AA foreach order. Consider this code: > ... > Output: > three > two > one > four > > I was sure output should be > one > two > three > four

Re: foreach for string[string]AA

2017-02-28 Thread Anton Pastukhov via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 15:44:46 UTC, bachmeier wrote: On Tuesday, 28 February 2017 at 15:33:46 UTC, ikod wrote: AA implemented as hash table, so it doesn't preserve insertion order. You have to sort keys when you need: import std.algorithm; import std.stdio; void main() {

Re: foreach for string[string]AA

2017-02-28 Thread Anton Pastukhov via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 17:16:43 UTC, Daniel Kozák wrote: V Tue, 28 Feb 2017 15:15:00 + Anton Pastukhov via Digitalmars-d-learn napsáno: I can't see the logic in AA foreach order. Consider this code: ... Output: three two one four I was sure

Mixing libraries

2017-02-28 Thread Jordan Wilson via Digitalmars-d-learn
Hello, Been trying to learn the Simple Fast Multimedia Library (SFML) using the Derelict bindings, and noticed some functionality is offered by both SFML and the std library (for example, sfClock and sfMutex). Is there a general design principle of, say, use the std library whenever

Re: code D'ish enough? - ignore previous post with same subject

2017-02-28 Thread crimaniak via Digitalmars-d-learn
On Sunday, 26 February 2017 at 21:50:38 UTC, Jordan Wilson wrote: .map!(a => a.to!double) If lambda just calls another function you can pass it directly: == .map!(to!double)

Re: Getting underlying struct for parseJSON

2017-02-28 Thread Alexey H via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 20:48:33 UTC, Petar Kirov [ZombineDev] wrote: On Tuesday, 28 February 2017 at 20:27:25 UTC, Alexey H wrote: Hello, guys! I'm working on a project that involves parsing of huge JSON datasets in real-time. Just an example of what i'm dealing with is here:

Re: code D'ish enough? - ignore previous post with same subject

2017-02-28 Thread Jordan Wilson via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 20:49:39 UTC, crimaniak wrote: On Sunday, 26 February 2017 at 21:50:38 UTC, Jordan Wilson wrote: .map!(a => a.to!double) If lambda just calls another function you can pass it directly: == .map!(to!double) Learn something new everyday, thanks :-)

Getting underlying struct for parseJSON

2017-02-28 Thread Alexey H via Digitalmars-d-learn
Hello, guys! I'm working on a project that involves parsing of huge JSON datasets in real-time. Just an example of what i'm dealing with is here: https://gist.githubusercontent.com/gdmka/125014058bb7d7f01b867fac56300a61/raw/f0c6b5be5fb01b16dd83f07c577b72f76f72c855/data.json Can't think of

Re: Getting underlying struct for parseJSON

2017-02-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 20:27:25 UTC, Alexey H wrote: So, my real question is: can i actually, by any change, get the description of an underlying struct that the call to parseJSON generates? It doesn't actually generate one, it just returns a tagged union (a kind of dynamic type).

Re: Getting underlying struct for parseJSON

2017-02-28 Thread via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 20:27:25 UTC, Alexey H wrote: Hello, guys! I'm working on a project that involves parsing of huge JSON datasets in real-time. Just an example of what i'm dealing with is here:

Re: Getting underlying struct for parseJSON

2017-02-28 Thread Seb via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 20:48:33 UTC, Petar Kirov [ZombineDev] wrote: On Tuesday, 28 February 2017 at 20:27:25 UTC, Alexey H wrote: [...] If you really care about performance, have a look this: http://forum.dlang.org/post/20151014090114.60780ad6@marco-toshiba std.json is not tuned

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-28 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 00:22:28 UTC, sarn wrote: If you ever have doubts, you can always use something like this to check: assert (__ctfe); Sorry, "enforce" would more appropriate if you're really checking. if (!__ctfe) assert(false); ... might be the best option. That

Re: Mixing libraries

2017-02-28 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 20:08:25 UTC, Jordan Wilson wrote: Hello, Been trying to learn the Simple Fast Multimedia Library (SFML) using the Derelict bindings, and noticed some functionality is offered by both SFML and the std library (for example, sfClock and sfMutex). Is there a

Alignment of struct containing SIMD field - GDC

2017-02-28 Thread Cecil Ward via Digitalmars-d-learn
struct vec_struct { alias field this; bool b; int8 field; } In this code when you look at the generated x64 code output by GDC it seems to be doing a nice job, because it has got the offset right for the 256-bit YMM 'field' correct. Does D automatically propagate the

How do I get names of regex captures during iteration? Populate AAs with captures?

2017-02-28 Thread Chad Joan via Digitalmars-d-learn
Is there a way to get the name of a named capture when iterating over captures from a regular expression match? I've looked at the std.regex code and it seems like "no" to my eyes, but I wonder if others here have... a way. My original problem is this: I need to populate an associative