Re: Is there a function for this?

2018-10-08 Thread Piotr Mitana via Digitalmars-d-learn
On Saturday, 6 October 2018 at 13:17:22 UTC, bauss wrote: Let's say you have a range with struct, but some of the struct are duplicates of each other. Is there a standard function in Phobos to remove duplicates? My first thought was "uniq", but it can't really do it like that, but it doesn't

Is there an efficient byte buffer queue?

2018-10-08 Thread John Burton via Digitalmars-d-learn
My use case is sending data to a socket. One part of my program generates blocks of bytes, and the socket part tries to send them to the socket and then removes from the queue the number that got sent. I am currently using a byte[] and using concatenation and slicing to maintain the queue bu

Re: Is there an efficient byte buffer queue?

2018-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 8 October 2018 at 09:39:55 UTC, John Burton wrote: My use case is sending data to a socket. One part of my program generates blocks of bytes, and the socket part tries to send them to the socket and then removes from the queue the number that got sent. [...] Try searching for "c

Re: Data structures and algorithms in D?

2018-10-08 Thread bauss via Digitalmars-d-learn
On Monday, 8 October 2018 at 06:15:46 UTC, eastanon wrote: On Monday, 8 October 2018 at 05:18:35 UTC, bauss wrote: On Sunday, 7 October 2018 at 20:27:47 UTC, eastanon wrote: Are there reading resources on Data structures and Algorithms in D? There are several such books in the C/C++ and Java w

Details on how aggregates are constructed with `new` and later destroyed by the GC

2018-10-08 Thread Per Nordlöw via Digitalmars-d-learn
I want to understand how calls to `new` for classes and structs are lowered by the compiler and druntime to a GC-allocation (specifically how the `ba`-argument bits are determined) followed by an initialization using default constructor or via a user-defined constructor called using arguments t

Re: Details on how aggregates are constructed with `new` and later destroyed by the GC

2018-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 8 October 2018 at 11:19:40 UTC, Per Nordlöw wrote: I want to understand how calls to `new` for classes see _d_newclass and structs are lowered by the compiler and druntime to a GC-allocation (specifically how the `ba`-argument bits are determined) followed by an initialization usi

Re: Details on how aggregates are constructed with `new` and later destroyed by the GC

2018-10-08 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 8 October 2018 at 11:19:40 UTC, Per Nordlöw wrote: And how this is related to the trait `hasElaborateConstructor` for both `classes` and `structs`. There's no such trait as far as I'm aware. If there were, it'd likely be checking for the presence of a '__ctor' member. Thing is, it

Re: Data structures and algorithms in D?

2018-10-08 Thread ShadoLight via Digitalmars-d-learn
On Sunday, 7 October 2018 at 20:27:47 UTC, eastanon wrote: Are there reading resources on Data structures and Algorithms in D? There are several such books in the C/C++ and Java world and many senior/experienced D users might have come across them in C. But for people who join D after reading A

Re: Data structures and algorithms in D?

2018-10-08 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2018-10-08 at 11:12 +, bauss via Digitalmars-d-learn wrote: > On Monday, 8 October 2018 at 06:15:46 UTC, eastanon wrote: > > On Monday, 8 October 2018 at 05:18:35 UTC, bauss wrote: > > > On Sunday, 7 October 2018 at 20:27:47 UTC, eastanon wrote: > > > > Are there reading resources on Da

Re: Data structures and algorithms in D?

2018-10-08 Thread Alex via Digitalmars-d-learn
On Sunday, 7 October 2018 at 20:27:47 UTC, eastanon wrote: Are there reading resources on Data structures and Algorithms in D? There are several such books in the C/C++ and Java world and many senior/experienced D users might have come across them in C. But for people who join D after reading A

Re: Can't Compile Global Semaphores?

2018-10-08 Thread Matt Richardson via Digitalmars-d-learn
On Monday, 27 July 2015 at 20:57:00 UTC, Jack Stouffer wrote: On Monday, 27 July 2015 at 20:12:10 UTC, John Colvin wrote: Yes, but then core.sync.semaphore doesn't support being shared, so... Ok, so I made the code run by using __gshared instead of shared. It seems really odd that a semaphore

Re: Can't Compile Global Semaphores?

2018-10-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/10/2018 4:43 AM, Matt Richardson wrote: On Monday, 27 July 2015 at 20:57:00 UTC, Jack Stouffer wrote: On Monday, 27 July 2015 at 20:12:10 UTC, John Colvin wrote: Yes, but then core.sync.semaphore doesn't support being shared, so... Ok, so I made the code run by using __gshared instead o

Re: Data structures and algorithms in D?

2018-10-08 Thread eastanon via Digitalmars-d-learn
On Monday, 8 October 2018 at 13:47:44 UTC, Russel Winder wrote: The purpose of these books is for students to learn the academic material, not the creation of production libraries. Most programming language libraries have all the algorithms coded up in the libraries. And for those algorithms th

Re: Can't Compile Global Semaphores?

2018-10-08 Thread Adam D. Ruppe via Digitalmars-d-learn
I recently rewrote some of my threading code in cgi.d and used the core.sync.semaphore with core.threads... never once used shared or __gshared. I just passed the handle of the semaphore to the new thread constructor. All seems to work.

Trying to make FreeList Allocator example compile

2018-10-08 Thread Per Nordlöw via Digitalmars-d-learn
I'm trying to compile the example import std.experimental.allocator.building_blocks.free_list : FreeList; theAllocator = allocatorObject(FreeList!8()); at https://dlang.org/phobos/std_experimental_allocator.html but fails first because of missing import import std.experimental.a

Re: Trying to make FreeList Allocator example compile

2018-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 8 October 2018 at 21:50:33 UTC, Per Nordlöw wrote: I'm trying to compile the example import std.experimental.allocator.building_blocks.free_list : FreeList; theAllocator = allocatorObject(FreeList!8()); at https://dlang.org/phobos/std_experimental_allocator.html but fails