Safely wrapping an uncopyable struct to implement an interface

2020-03-04 Thread Gregor Mückl via Digitalmars-d-learn
Hi! I've just created a situation in my code that is summarized by the following example. I don't know how to solve it with @safe code. A third party library provides a struct that is not copyable: // provided by third party struct Foo { @disable this() @safe; @disable this(ref retur

Re: Improving dot product for standard multidimensional D arrays

2020-03-04 Thread Timon Gehr via Digitalmars-d-learn
On 01.03.20 21:58, p.shkadzko wrote: ** Matrix!T matrixDotProduct(T)(Matrix!T m1, Matrix!T m2) in {     assert(m1.rows == m2.cols); This asserts that the result is a square matrix. I think you want `m1.cols==m2.rows` instead.

Re: Safely wrapping an uncopyable struct to implement an interface

2020-03-04 Thread aliak via Digitalmars-d-learn
On Wednesday, 4 March 2020 at 12:03:48 UTC, Gregor Mückl wrote: Hi! I've just created a situation in my code that is summarized by the following example. I don't know how to solve it with @safe code. A third party library provides a struct that is not copyable: // provided by third party st

Re: Safely wrapping an uncopyable struct to implement an interface

2020-03-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/4/20 9:04 AM, aliak wrote: On Wednesday, 4 March 2020 at 12:03:48 UTC, Gregor Mückl wrote: Hi! I've just created a situation in my code that is summarized by the following example. I don't know how to solve it with @safe code. A third party library provides a struct that is not copyable

spawn a function with object as arg?

2020-03-04 Thread Martin Brezel via Digitalmars-d-learn
I want to create a Client, which receives and handles received data in background while the Client can send via the same socket. My first idea was something like this: class Client { private Socket socket; private Tid receiverTid; this(Socket socket) {

Re: spawn a function with object as arg?

2020-03-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 4 March 2020 at 23:37:00 UTC, Martin Brezel wrote: The documentation for spawn() states: "all arguments to fn must either be shared or immutable or have no pointer indirection." The easiest thing to do is to just cast import std.concurrency; import std.socket; void main() {

Nice readable code with initializer

2020-03-04 Thread Виталий Фадеев via Digitalmars-d-learn
Searching for beauty code implementation. Goal is: Create new object with "custom initializer". "custom initializer" - is function, executed in _ctor, in object scope. Main Goal is: "clean readable beauty code". Like this and better: class DataGrid : Base { this() { super()

Re: Nice readable code with initializer

2020-03-04 Thread Виталий Фадеев via Digitalmars-d-learn
On Thursday, 5 March 2020 at 06:48:53 UTC, Виталий Фадеев wrote: Searching for beauty code implementation. Goal is: Create new object with "custom initializer". "custom initializer" - is function, executed in _ctor, in object scope. Main Goal is: "clean readable beauty code". Like this and

Converting Lua source to D

2020-03-04 Thread Jesse Phillips via Digitalmars-d-learn
I am making an attempt convert Lua to D. This is less about the conversion and more about exploring the tooling to make it happen. I have chosen to do this file by file and attempting to start with linint. I wanted to make use of dpp, however I hit a segmentation fault and reduced dependency.

What does assigning void mean?

2020-03-04 Thread mark via Digitalmars-d-learn
In Adam Ruppe's D Cookbook there're these lines in a ref counting example: RefCountedObject o = void; // What does this mean/do? o.data = new Implementation(); o.data.refcount = 1; I don't understand the first line; could someone explain please?