Re: 2D arrays, slices and manual memory allocation

2022-02-24 Thread Nonobvious via Digitalmars-d-learn
On Friday, 25 February 2022 at 06:13:35 UTC, 9il wrote: On Friday, 25 February 2022 at 06:03:34 UTC, Nonobvious wrote: From [Go Your Own Way (Part Two: The Heap)](https://dlang.org/blog/2017/09/25/go-your-own-way-part-two-the-heap/): [...]

Re: 2D arrays, slices and manual memory allocation

2022-02-24 Thread 9il via Digitalmars-d-learn
On Friday, 25 February 2022 at 06:03:34 UTC, Nonobvious wrote: From [Go Your Own Way (Part Two: The Heap)](https://dlang.org/blog/2017/09/25/go-your-own-way-part-two-the-heap/): [...] http://mir-algorithm.libmir.org/mir_ndslice_allocation.html#.stdcUninitSlice

2D arrays, slices and manual memory allocation

2022-02-24 Thread Nonobvious via Digitalmars-d-learn
From [Go Your Own Way (Part Two: The Heap)](https://dlang.org/blog/2017/09/25/go-your-own-way-part-two-the-heap/): `import core.stdc.stdlib;` `// Allocate a block of untyped bytes that can be managed` `// as a slice.` `void[] allocate(size_t size)` `{` `// malloc(0) is

Re: How to check that a member function is generated by compiler?

2022-02-24 Thread Ali Çehreli via Digitalmars-d-learn
On 2/24/22 20:44, Andrey Zherikov wrote: How can I check that `opAssign` is generated by compiler and doesn't exist in the original code? I think this one: https://dlang.org/phobos/std_traits.html#hasElaborateAssign Ali

How to check that a member function is generated by compiler?

2022-02-24 Thread Andrey Zherikov via Digitalmars-d-learn
This code ```d import std.sumtype: SumType; struct A { SumType!int b; } static foreach(sym; __traits(allMembers, A)) pragma(msg,sym); ``` prints ``` b opAssign ``` How can I check that `opAssign` is generated by compiler and doesn't exist in the original code?

Re: Tips on TCP socket to postgresql middleware

2022-02-24 Thread eugene via Digitalmars-d-learn
On Thursday, 24 February 2022 at 11:27:56 UTC, Tejas wrote: Wagner F. et al Modeling Software with Finite State Machines: A Practical Approach I've adopted some ideas from this book to POSIX/Linux API. see also http://www.stateworks.com/ Thank you so much! Also there is [very nice

Re: Tips on TCP socket to postgresql middleware

2022-02-24 Thread eugene via Digitalmars-d-learn
On Thursday, 24 February 2022 at 09:11:01 UTC, eugene wrote: In my case (I was working with REDIS KVS at the moment) exact scenario was as follows: * prog gets EPOLLOUT (write() won't block) * prog writes()'s data to REDIS ("successfully") * prog gets EPOLLERR|EPOLLHUP After this I see that I

Re: Tips on TCP socket to postgresql middleware

2022-02-24 Thread Tejas via Digitalmars-d-learn
On Thursday, 24 February 2022 at 06:54:07 UTC, eugene wrote: On Thursday, 24 February 2022 at 06:30:51 UTC, Tejas wrote: On Wednesday, 23 February 2022 at 09:34:56 UTC, eugene wrote: On Tuesday, 22 February 2022 at 20:19:39 UTC, Chris Piker wrote: [...] As you might have been already noted,

Re: Tips on TCP socket to postgresql middleware

2022-02-24 Thread eugene via Digitalmars-d-learn
On Thursday, 24 February 2022 at 08:46:35 UTC, eugene wrote: On Saturday, 19 February 2022 at 20:13:01 UTC, Chris Piker wrote: 3. Update/insert to a postgresql database as data arrive. I've remembered one not so obvious feature of TCP sockets behavour. If the connection is closed on the

Re: Tips on TCP socket to postgresql middleware

2022-02-24 Thread eugene via Digitalmars-d-learn
On Saturday, 19 February 2022 at 20:13:01 UTC, Chris Piker wrote: 3. Update/insert to a postgresql database as data arrive. I've remembered one not so obvious feature of TCP sockets behavour. If the connection is closed on the server side (i.e. on the client side the socket is in CLOSE_WAIT

Re: how to return map(fn)

2022-02-24 Thread steve via Digitalmars-d-learn
float times_two(float x) {return 2*x;} // if you would rather make sure the result is an array float[] times_two_array(float[] arr) { import std.algorithm; // for map import std.array; // for array return arr .map!times_two // map your function .array; // convert to an array