Re: how to append (ref) int[] to int[][]?

2020-06-07 Thread mw via Digitalmars-d-learn
On Monday, 8 June 2020 at 06:42:44 UTC, Simen Kjærås wrote: Arrays (technically, slices) in D are essentially this struct: struct Array(T) { T* ptr; size_t length; // operator overloads } So when you have int[][], each element of the outer array is an Array!int. These, as simple s

Re: how to append (ref) int[] to int[][]?

2020-06-07 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 8 June 2020 at 06:13:36 UTC, mw wrote: Hi, I have this program: import std.stdio; void f(ref int[] arr) { arr ~= 3; } void main() { int[][] arrs; int[] arr; foreach (i; 0 .. 3) { arr

non-constant expression while initializing two dim array

2020-06-07 Thread tirithen via Digitalmars-d-learn
How can I initialize my two dimensional array? When I try to run the code below I get the error: Error: non-constant expression ["user":[cast(Capability)0], "administrator":[cast(Capability)1]] Code: enum Capability { self, administer } alias Capabilities = immut

how to append (ref) int[] to int[][]?

2020-06-07 Thread mw via Digitalmars-d-learn
Hi, I have this program: import std.stdio; void f(ref int[] arr) { arr ~= 3; } void main() { int[][] arrs; int[] arr; foreach (i; 0 .. 3) { arr = new int[0]; arrs ~= arr; //(a) [

Re: Mixin and imports

2020-06-07 Thread Mike Parker via Digitalmars-d-learn
On Monday, 8 June 2020 at 02:55:25 UTC, jmh530 wrote: In the code below, foo!fabs compiles without issue, but foo!"fabs" does not because the import is not available in the string mixin. If I move the import to the top of the module, then it works. However, then if I move foo to another module,

Mixin and imports

2020-06-07 Thread jmh530 via Digitalmars-d-learn
In the code below, foo!fabs compiles without issue, but foo!"fabs" does not because the import is not available in the string mixin. If I move the import to the top of the module, then it works. However, then if I move foo to another module, then it will no longer compile since it is in differe

Re: Arrays and non-copyable elements

2020-06-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/7/20 10:07 PM, Stanislav Blinov wrote: On Monday, 8 June 2020 at 00:31:10 UTC, Steven Schveighoffer wrote: This is a bug, please file. What is likely happening is that the template is not moving the data to the underlying C call. That is not a bug, it's a shortcoming of garbage-collect

Re: Arrays and non-copyable elements

2020-06-07 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 8 June 2020 at 00:31:10 UTC, Steven Schveighoffer wrote: This is a bug, please file. What is likely happening is that the template is not moving the data to the underlying C call. -Steve That is not a bug, it's a shortcoming of garbage-collected arrays. D arrays are not equipped

Re: Should it compile?

2020-06-07 Thread Stanislav Blinov via Digitalmars-d-learn
On Sunday, 7 June 2020 at 23:09:41 UTC, Jack Applegame wrote: auto const_ua = Unique!(const NonCopyable)(move(ca)); // error, why??? } ``` Moving *from* a const would violate const. At least, until such time that the compiler is finally taught about move() (hopefully, sometime this deca

Re: Arrays and non-copyable elements

2020-06-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/7/20 7:25 PM, Jack Applegame wrote: I think it should compile. ``` struct NonCopyable {     int a;     this(this) @disable; } void main() {     NonCopyable[] arr = [NonCopyable(1), NonCopyable(2)]; // ok     arr ~= NonCopyable(3); // fails } ``` This is a bug, please file. What is li

Re: Should it compile?

2020-06-07 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 7 June 2020 at 23:09:41 UTC, Jack Applegame wrote: const NonCopyable const_a; auto const_ua = Unique!(const NonCopyable)(move(ca)); // error, why??? You can't move from a const variable.

Arrays and non-copyable elements

2020-06-07 Thread Jack Applegame via Digitalmars-d-learn
I think it should compile. ``` struct NonCopyable { int a; this(this) @disable; } void main() { NonCopyable[] arr = [NonCopyable(1), NonCopyable(2)]; // ok arr ~= NonCopyable(3); // fails } ```

Re: Should it compile?

2020-06-07 Thread Jack Applegame via Digitalmars-d-learn
On Saturday, 6 June 2020 at 11:58:06 UTC, Basile B. wrote: maybe it shouldn't but then with another message, for example Error, cannot `void` initialize a `const` declaration. since that makes very little sense, at least as a local variable. (as a member, this can be initialized in a cons

Re: Should it compile?

2020-06-07 Thread Jack Applegame via Digitalmars-d-learn
On Saturday, 6 June 2020 at 12:02:03 UTC, MoonlightSentinel wrote: On Saturday, 6 June 2020 at 08:55:20 UTC, Jack Applegame wrote: Should it compile? No, moveEmplace just sees a const reference and doesn't know that a is void-initialized. Actually, it knows. Because moveEmplace assumes target

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 7 June 2020 at 16:26:17 UTC, Andre Pany wrote: On Sunday, 7 June 2020 at 15:37:27 UTC, Paul Backus wrote: On Sunday, 7 June 2020 at 12:52:12 UTC, Andre Pany wrote: I am not sure but $DUB is a variable which could be used in dub descriptor file but it isn't an environment variable.

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Andre Pany via Digitalmars-d-learn
On Sunday, 7 June 2020 at 15:37:27 UTC, Paul Backus wrote: On Sunday, 7 June 2020 at 12:52:12 UTC, Andre Pany wrote: I am not sure but $DUB is a variable which could be used in dub descriptor file but it isn't an environment variable. $DUB_EXE is an environment variable. Kind regards Andre

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 7 June 2020 at 12:52:12 UTC, Andre Pany wrote: I am not sure but $DUB is a variable which could be used in dub descriptor file but it isn't an environment variable. $DUB_EXE is an environment variable. Kind regards Andre If what you say is true, the Dub documentation needs to be

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Basile B. via Digitalmars-d-learn
On Sunday, 7 June 2020 at 12:24:13 UTC, Russel Winder wrote: On Sun, 2020-06-07 at 10:30 +, Basile B. via Digitalmars-d-learn wrote: […] What is the docker image that you use ? If it is an older version maybe that the $DUB env variable is not yet supported by the dub version that's install

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Andre Pany via Digitalmars-d-learn
On Sunday, 7 June 2020 at 10:06:14 UTC, Russel Winder wrote: On Sun, 2020-06-07 at 10:24 +0100, Russel Winder wrote: Hi, Why on earth is Dub sending out this error message (Invalid variable: DUB) on GitLab but not on Travis-CI or locally? OK, that was slightly rhetorical, more reasonably, wh

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Andre Pany via Digitalmars-d-learn
On Sunday, 7 June 2020 at 11:21:03 UTC, Jacob Carlborg wrote: On 2020-06-07 11:24, Russel Winder wrote: Hi, Why on earth is Dub sending out this error message (Invalid variable: DUB) on GitLab but not on Travis-CI or locally? OK, that was slightly rhetorical, more reasonably, why is dub sen

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2020-06-07 at 13:21 +0200, Jacob Carlborg via Digitalmars-d-learn wrote: > On 2020-06-07 11:24, Russel Winder wrote: > > Hi, > > > > Why on earth is Dub sending out this error message (Invalid variable: DUB) > > on > > GitLab but not on Travis-CI or locally? > > > > OK, that was slightly

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2020-06-07 at 10:30 +, Basile B. via Digitalmars-d-learn wrote: […] > What is the docker image that you use ? If it is an older > version maybe that the $DUB env variable is not yet supported by > the dub version that's installed (it exists since 2.084.0 > according to [1]). I am u

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-06-07 11:24, Russel Winder wrote: Hi, Why on earth is Dub sending out this error message (Invalid variable: DUB) on GitLab but not on Travis-CI or locally? OK, that was slightly rhetorical, more reasonably, why is dub sending out this message at all? Dub is supposed to make an environ

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Basile B. via Digitalmars-d-learn
On Sunday, 7 June 2020 at 10:06:14 UTC, Russel Winder wrote: On Sun, 2020-06-07 at 10:24 +0100, Russel Winder wrote: Hi, Why on earth is Dub sending out this error message (Invalid variable: DUB) on GitLab but not on Travis-CI or locally? OK, that was slightly rhetorical, more reasonably, wh

Travis-CI and testing D builds

2020-06-07 Thread Russel Winder via Digitalmars-d-learn
Hi, The Travis-CI D language image for dist bionic still seems to be build on Xenial. Is this as it should be? -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2020-06-07 at 10:24 +0100, Russel Winder wrote: > Hi, > > Why on earth is Dub sending out this error message (Invalid variable: DUB) > on > GitLab but not on Travis-CI or locally? > > OK, that was slightly rhetorical, more reasonably, why is dub sending out > this > message at all? I am

Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Russel Winder via Digitalmars-d-learn
Hi, Why on earth is Dub sending out this error message (Invalid variable: DUB) on GitLab but not on Travis-CI or locally? OK, that was slightly rhetorical, more reasonably, why is dub sending out this message at all? -- Russel. === Dr Russel Winder t