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

2017-07-03 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 4 July 2017 at 03:13:14 UTC, Filip Bystricky wrote: Oh and I forgot to mention: another use-case for this would be for arrays. For manually managed arrays like std.container.array, it would make it possible to transfer ownership of individual objects from the array back to the

Re: Finding all the interfaces and their inheritance relationships at runtime

2017-07-03 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Monday, 3 July 2017 at 22:34:51 UTC, FoxyBrown wrote: On Monday, 3 July 2017 at 20:45:19 UTC, bauss wrote: On Monday, 3 July 2017 at 13:54:42 UTC, Jean-Louis Leroy wrote: I know how to find all the classes: foreach (mod; ModuleInfo) { foreach (c; mod.localClasses) { //

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

2017-07-03 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 4 July 2017 at 02:53:00 UTC, Filip Bystricky wrote: On Tuesday, 4 July 2017 at 01:56:11 UTC, Moritz Maxeiner wrote: [...] However, in many cases it is unacceptable to have to prevent the whole block from being freed (especially if the memory is managed by a compacting gc).

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

2017-07-03 Thread Filip Bystricky via Digitalmars-d-learn
Oh and I forgot to mention: another use-case for this would be for arrays. For manually managed arrays like std.container.array, it would make it possible to transfer ownership of individual objects from the array back to the program after the array goes out of scope. For gc slices, it could

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

2017-07-03 Thread Filip Bystricky via Digitalmars-d-learn
On Tuesday, 4 July 2017 at 01:56:11 UTC, Moritz Maxeiner wrote: On Monday, 3 July 2017 at 17:06:10 UTC, Ali Çehreli wrote: On 07/02/2017 07:56 PM, Stefan Koch wrote: On Monday, 3 July 2017 at 02:51:49 UTC, Filip Bystricky wrote: Anyone? The answer is no. Partial deallocation in an

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

2017-07-03 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 3 July 2017 at 17:06:10 UTC, Ali Çehreli wrote: On 07/02/2017 07:56 PM, Stefan Koch wrote: 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

Re: Funny issue with casting double to ulong

2017-07-03 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 03, 2017 at 07:13:45AM +, Era Scarecrow via Digitalmars-d-learn wrote: > On Monday, 3 July 2017 at 06:20:22 UTC, H. S. Teoh wrote: [...] > > I don't think there's a way to change how the FPU works -- the > > hardware is coded that way and can't be changed. You'd have to > > build

Re: Finding all the interfaces and their inheritance relationships at runtime

2017-07-03 Thread FoxyBrown via Digitalmars-d-learn
On Monday, 3 July 2017 at 20:45:19 UTC, bauss wrote: On Monday, 3 July 2017 at 13:54:42 UTC, Jean-Louis Leroy wrote: I know how to find all the classes: foreach (mod; ModuleInfo) { foreach (c; mod.localClasses) { // use c.base to construct inheritance graph } } Can

Re: Finding all the interfaces and their inheritance relationships at runtime

2017-07-03 Thread bauss via Digitalmars-d-learn
On Monday, 3 July 2017 at 13:54:42 UTC, Jean-Louis Leroy wrote: I know how to find all the classes: foreach (mod; ModuleInfo) { foreach (c; mod.localClasses) { // use c.base to construct inheritance graph } } Can I do the same with all the interfaces? Looking at

Re: Accessing part of a struct in an easy way

2017-07-03 Thread Paolo Invernizzi via Digitalmars-d-learn
On Monday, 3 July 2017 at 17:30:51 UTC, Ali Çehreli wrote: hOn 07/03/2017 10:13 AM, Paolo Invernizzi wrote: > [...] struct with > [...] I had difficulty understanding the requirements. For example, it's not clear whether you want the literal "first" and "second" names. [...] Thanks Ali,

Re: Accessing part of a struct in an easy way

2017-07-03 Thread Ali Çehreli via Digitalmars-d-learn
hOn 07/03/2017 10:13 AM, Paolo Invernizzi wrote: > It's not exactly the same, as first and second should be struct with > partial fields from Foo, of different types. I had difficulty understanding the requirements. For example, it's not clear whether you want the literal "first" and "second"

Re: Accessing part of a struct in an easy way

2017-07-03 Thread Paolo Invernizzi via Digitalmars-d-learn
On Monday, 3 July 2017 at 16:41:51 UTC, vit wrote: On Monday, 3 July 2017 at 13:53:45 UTC, Paolo Invernizzi wrote: [...] //https://dpaste.dzfl.pl/d59469c264b2 import std.algorithm : map, copy, equal; import std.range : iota; struct Foo { int[3] a; string[2] b; } ref T first(R :

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

2017-07-03 Thread Ali Çehreli via Digitalmars-d-learn
On 07/02/2017 07:56 PM, Stefan Koch wrote: 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. Would it be possible to write a custom

Re: Accessing part of a struct in an easy way

2017-07-03 Thread vit via Digitalmars-d-learn
On Monday, 3 July 2017 at 13:53:45 UTC, Paolo Invernizzi wrote: I've struct like that: struct Foo { int a_1; float a_2; string a_3; string b_1; double b_2; } I would like to transparently access that like: foo.a.first foo.b.second = "baz"; with an helper like: auto a(...) { ... }

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

2017-07-03 Thread ketmar via Digitalmars-d-learn
Yuri wrote: On Monday, 3 July 2017 at 14:04:47 UTC, ketmar wrote: Yuri wrote: On Sunday, 2 July 2017 at 21:15:41 UTC, ketmar wrote: [...] I share your sentiment in relation to std.json, ketmar. On a side note, what would be a better way to serialize/deserialize objects in D if std.json

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

2017-07-03 Thread Yuri via Digitalmars-d-learn
On Monday, 3 July 2017 at 14:04:47 UTC, ketmar wrote: Yuri wrote: On Sunday, 2 July 2017 at 21:15:41 UTC, ketmar wrote: [...] I share your sentiment in relation to std.json, ketmar. On a side note, what would be a better way to serialize/deserialize objects in D if std.json does not cut

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

2017-07-03 Thread Yuri via Digitalmars-d-learn
On Monday, 3 July 2017 at 13:34:50 UTC, Adam D. Ruppe wrote: On Monday, 3 July 2017 at 13:26:52 UTC, Yuri wrote: Yes, when accessing .integer instead of .floating then it works, unfortunately that is not suitable for the task at hand, it has to be a float. Just write a helper function that

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

2017-07-03 Thread ketmar via Digitalmars-d-learn
Yuri wrote: On Sunday, 2 July 2017 at 21:15:41 UTC, ketmar wrote: so, write your own wrapper that will convert INTEGER/UINTEGER/FLOAT to `double`. i think this is the best solution (if there can be "best solution" with std.json at all). I share your sentiment in relation to std.json,

Finding all the interfaces and their inheritance relationships at runtime

2017-07-03 Thread Jean-Louis Leroy via Digitalmars-d-learn
I know how to find all the classes: foreach (mod; ModuleInfo) { foreach (c; mod.localClasses) { // use c.base to construct inheritance graph } } Can I do the same with all the interfaces? Looking at object.d gives no clue...

Accessing part of a struct in an easy way

2017-07-03 Thread Paolo Invernizzi via Digitalmars-d-learn
I've struct like that: struct Foo { int a_1; float a_2; string a_3; string b_1; double b_2; } I would like to transparently access that like: foo.a.first foo.b.second = "baz"; with an helper like: auto a(...) { ... } auto b(...) { ... } that can be used also in functions that are

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

2017-07-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 3 July 2017 at 13:26:52 UTC, Yuri wrote: Yes, when accessing .integer instead of .floating then it works, unfortunately that is not suitable for the task at hand, it has to be a float. Just write a helper function that casts it yourself: double numeric(JSONValue v) { if(v.type

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

2017-07-03 Thread Yuri via Digitalmars-d-learn
On Sunday, 2 July 2017 at 21:15:41 UTC, ketmar wrote: so, write your own wrapper that will convert INTEGER/UINTEGER/FLOAT to `double`. i think this is the best solution (if there can be "best solution" with std.json at all). I share your sentiment in relation to std.json, ketmar. On a side

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

2017-07-03 Thread Yuri via Digitalmars-d-learn
On Sunday, 2 July 2017 at 21:12:48 UTC, Adam D. Ruppe wrote: 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

Re: Funny issue with casting double to ulong

2017-07-03 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 3 July 2017 at 05:38:56 UTC, Era Scarecrow wrote: 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

Re: Need simple sound

2017-07-03 Thread Martin Tschierschke via Digitalmars-d-learn
On Monday, 3 July 2017 at 09:24:35 UTC, Guillaume Piolat wrote: On Monday, 3 July 2017 at 08:55:20 UTC, Martin Tschierschke wrote: Hello for a simple game I would like to add some very simple sound, not much different than the beeps of "PAC Man". Is there anything I can use for this?

Re: Funny issue with casting double to ulong

2017-07-03 Thread via Digitalmars-d-learn
On Monday, 3 July 2017 at 04:06:23 UTC, Saurabh Das wrote: 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

Re: Need simple sound

2017-07-03 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 3 July 2017 at 08:55:20 UTC, Martin Tschierschke wrote: Hello for a simple game I would like to add some very simple sound, not much different than the beeps of "PAC Man". Is there anything I can use for this? DerelictSDL supports the loading of SDL_mixer, which makes it very

Need simple sound

2017-07-03 Thread Martin Tschierschke via Digitalmars-d-learn
Hello for a simple game I would like to add some very simple sound, not much different than the beeps of "PAC Man". Is there anything I can use for this?

Re: Funny issue with casting double to ulong

2017-07-03 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 03, 2017 at 05:38:56AM +, Era Scarecrow via Digitalmars-d-learn wrote: > 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