Looking for a mentor in D

2017-10-02 Thread eastanon via Digitalmars-d-learn
I have been reading the D forums for a while and following on its amazing progress for a long time. Over time I have even written some basic D programs for myself, nothing major or earth shuttering. I have downloaded and read Ali's excellent book. I would like to dive deeper into D, however s

non-block reading from pipe stdout

2017-10-02 Thread Oleg B via Digitalmars-d-learn
Hello. I run program through std.process.pipeShell and want to read from it stdout in loop. How do this non-blocking? I try int fd = p.stdout.fileno; int flags = fcntl(fd, F_GETFL, 0); flags |= O_NONBLOCK; fcntl(fd, F_SETFL, flags); but get error "Resource tempo

Static introspection of suitable hash function depending on type of hash key

2017-10-02 Thread Nordlöw via Digitalmars-d-learn
Does anyone have any good reads on the subject of statically choosing suitable hash-functions depending on the type (and in turn size) of the key? I wonder because I'm currently experimenting with a hash set implementation at https://github.com/nordlow/phobos-next/blob/40e2973b74d58470a13a5a

Re: When to opCall instead of opIndex and opSlice?

2017-10-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/2/17 2:31 PM, Per Nordlöw wrote: On Monday, 2 October 2017 at 18:14:24 UTC, Jacob Carlborg wrote: On 2017-10-02 17:57, Nordlöw wrote: Is implementing opCall(size_t) for structures such as array containers that already define opIndex and opSlice deprecated? I can't find any documentation

Re: When to opCall instead of opIndex and opSlice?

2017-10-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 02, 2017 18:31:23 Per Nordlöw via Digitalmars-d-learn wrote: > On Monday, 2 October 2017 at 18:14:24 UTC, Jacob Carlborg wrote: > > On 2017-10-02 17:57, Nordlöw wrote: > >> Is implementing opCall(size_t) for structures such as array > >> containers that already define opIndex an

Re: When to opCall instead of opIndex and opSlice?

2017-10-02 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 2 October 2017 at 18:14:24 UTC, Jacob Carlborg wrote: On 2017-10-02 17:57, Nordlöw wrote: Is implementing opCall(size_t) for structures such as array containers that already define opIndex and opSlice deprecated? I can't find any documentation on the subject on when opCall should b

Re: When to opCall instead of opIndex and opSlice?

2017-10-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-02 17:57, Nordlöw wrote: Is implementing opCall(size_t) for structures such as array containers that already define opIndex and opSlice deprecated? I can't find any documentation on the subject on when opCall should be defined to enable foreach (isIterable). opCall is not related

When to opCall instead of opIndex and opSlice?

2017-10-02 Thread Nordlöw via Digitalmars-d-learn
Is implementing opCall(size_t) for structures such as array containers that already define opIndex and opSlice deprecated? I can't find any documentation on the subject on when opCall should be defined to enable foreach (isIterable).

Re: Struct bug?

2017-10-02 Thread Biotronic via Digitalmars-d-learn
On Monday, 2 October 2017 at 09:34:29 UTC, Andrea Fontana wrote: Anyway: you cant put a default destructor on struct True. In which case you should either @disable this() (which presents its own set of issues) or hide b behind a @property function, something like: struct S { B _b;

Re: Struct bug?

2017-10-02 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 2 October 2017 at 09:08:59 UTC, Biotronic wrote: Not knowing what you're attempting to do, I'm not sure how to fix your problem. But if what I've described above does indeed cover it, initializing b in the constructor is the way to get it to work. -- Biotronic Obviusly real exa

Re: Struct bug?

2017-10-02 Thread Biotronic via Digitalmars-d-learn
On Monday, 2 October 2017 at 08:47:47 UTC, Andrea Fontana wrote: Why this code doesn't write two identical lines? https://dpaste.dzfl.pl/e99aad315a2a Andrea A reduced example of where it goes wrong: class B {} struct A { B b = new B; } unittest { A a1, a2; assert(a1 == a2); }

Struct bug?

2017-10-02 Thread Andrea Fontana via Digitalmars-d-learn
Why this code doesn't write two identical lines? https://dpaste.dzfl.pl/e99aad315a2a Andrea