erlang NIF written in D?

2018-12-15 Thread Karl via Digitalmars-d-learn
I'm curious if it'd be possible to write erlang NIFs in D? From reading Interfacing to C, it seems like I'd need to generate a D interface file for the [not insignificant] erl_nif header, and then I'd be able to create a -shared file from D code and load it like any other shared object in Erla

Re: Can you move a disabled this(this) struct in to a container type if it's an rvalue?

2018-12-15 Thread Q. Schroll via Digitalmars-d-learn
On Thursday, 13 December 2018 at 23:33:39 UTC, Stanislav Blinov wrote: On Thursday, 13 December 2018 at 13:17:05 UTC, aliak wrote: Ah. Is there any case where you would not want to do that when you have a T value as parameter? Hypothetically, yes, e.g. an object that contains references to i

Orphan format arguments: args[0..1]

2018-12-15 Thread Ali Çehreli via Digitalmars-d-learn
This one confused me until I decided to talk to a rubber ducky: import std.string; void main() { auto s = "%s is a good number".format(42); } Fine; it works... Then the string becomes too long and I split it: auto s = "%s is a good number but one needs to know" ~ " what th

Re: Shared static this() not executed for unittest

2018-12-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, December 15, 2018 10:27:36 AM MST Neia Neutuladh via Digitalmars-d-learn wrote: > On Sat, 15 Dec 2018 17:19:05 +, Timoses wrote: > > Running `dub test` will output: > > Running ./unit-test-library writeln: unittest All unit tests have been > > run successfully. > > > > Why is the

Re: Native PDB Error

2018-12-15 Thread JN via Digitalmars-d-learn
On Saturday, 15 December 2018 at 20:54:03 UTC, JN wrote: Bump. Encountering the same issue. Just reinstalled Windows and having the same error on DMD32 D Compiler v2.083.1 . OK, fixed it. Since it's the first hit from Google, here's a solution: https://www.reddit.com/r/roguelikedev/commen

Re: Native PDB Error

2018-12-15 Thread JN via Digitalmars-d-learn
On Wednesday, 7 November 2018 at 14:43:07 UTC, Chris M. wrote: On Wednesday, 7 November 2018 at 01:37:29 UTC, Chris M. wrote: On Tuesday, 29 May 2018 at 07:47:07 UTC, Begah wrote: [...] This works fine on my home Win10 machine, dmd 2.082/2.083 + dub 1.11.0, installed using the executable fro

mir.ndslice: assign a vector to a matrix row

2018-12-15 Thread David via Digitalmars-d-learn
Hi I am wondering if it is possible to assign a vector to a row of a matrix? main.d == import mir.ndslice; void main() { auto matrix = slice!double(3, 4); matrix[] = 0; matrix.diagonal[] = 1; auto row = matrix[0]; row[3] = 4; assert(matrix[0, 3] == 4); //

Re: Shared static this() not executed for unittest

2018-12-15 Thread Timoses via Digitalmars-d-learn
A look into `dub test --vverbose` showed that ./source/app.d is not even included in the compilcation step...

Re: Shared static this() not executed for unittest

2018-12-15 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 15 Dec 2018 17:19:05 +, Timoses wrote: > Running `dub test` will output: > Running ./unit-test-library writeln: unittest All unit tests have been > run successfully. > > Why is the `shared static this()` not executed? Run `dub clean; dub test -v` and you'll see that main.d isn't compi

Shared static this() not executed for unittest

2018-12-15 Thread Timoses via Digitalmars-d-learn
Spec 27.5 states: "Unit tests, when enabled, are run after all static initialization is complete and before the main() function is called. " (https://dlang.org/spec/unittest.html) main.d: --- import std.stdio; shared static this() { import vibe.core.log; setLogLevel(Lo

Re: How to initialize a globle variable nicely and properly?

2018-12-15 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 15 Dec 2018 13:49:03 +, Heromyth wrote: > Yes, it's very dangerous to create a new thread in shared static this(). > For a big project, it sometimes hard to identify this problem. Maybe, > the compiler should do something for this, should it? The runtime, more likely. There are plenty

Re: How to initialize a globle variable nicely and properly?

2018-12-15 Thread Heromyth via Digitalmars-d-learn
On Saturday, 15 December 2018 at 03:48:15 UTC, Neia Neutuladh wrote: On Sat, 15 Dec 2018 02:54:55 +, Heromyth wrote: shared static this() { writeln("running A in shared static this(), sharedField=", sharedField); Thread th = new Thread(() { }); th.start();

How to define class type array?

2018-12-15 Thread Brian via Digitalmars-d-learn
Java code: ```java class A extends Node {} class B extends Node {} class C extends Node {} @Override public Set> getNodes() { return new HashSet<>(Arrays.asList( A.class, B.class, C.class )); } ``` For dlang like this? `

Re: Can you move a disabled this(this) struct in to a container type if it's an rvalue?

2018-12-15 Thread aliak via Digitalmars-d-learn
On Thursday, 13 December 2018 at 23:33:39 UTC, Stanislav Blinov wrote: On Thursday, 13 December 2018 at 13:17:05 UTC, aliak wrote: [...] Hypothetically, yes, e.g. an object that contains references to itself. However, D operates on the assumption that you don't have such objects. And even t