Re: Structured binding declaration (like in C++)

2021-10-14 Thread MoonlightSentinel via Digitalmars-d-learn
On Wednesday, 13 October 2021 at 20:02:05 UTC, Vindex wrote: Is there a decomposition for tuples and other data structures? No, but you can emulate it, e.g. by using AliasSeq: ```d import std.meta : AliasSeq; import std.typecons : tuple; import std.stdio : writeln; void main() { int a;

Re: Download a file into array (using std.net.curl.download)

2021-07-07 Thread MoonlightSentinel via Digitalmars-d-learn
On Wednesday, 7 July 2021 at 10:27:47 UTC, notna wrote: On Windows: [...] Nice and helpful Error messages is on the top of our desires list, right? It's hard to give proper error backtraces without debug information (-g). Anyways, I can reproduce the error when compiling with `-m32` (the

Re: Download a file into array (using std.net.curl.download)

2021-07-05 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 5 July 2021 at 14:57:20 UTC, BoQsc wrote: Let's say I can't store information into files. Is it possible to download a file into an array. Yes, use [`get`](https://dlang.org/phobos/std_net_curl.html#.get): ```d import std.net.curl; void main() { char[] content =

Re: how do i fix this node_dlang error?

2021-06-07 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 7 June 2021 at 19:03:44 UTC, Jack wrote: actually i didnt so I just added: ```d shared static this() { Runtime.initialize(); } shared static ~this() { Runtime.terminate(); } ``` but it didn't change anything That doesn't work because `Runtime.initialize()` is

Re: how do i fix this node_dlang error?

2021-06-07 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 7 June 2021 at 02:33:38 UTC, Jack wrote: What am I missing? Does your code / `node_dlang` initialize Druntime before calling `writeln`? Try replacing the `writeln` with `puts` (from `core.stdc.stdio`) which doesn't require an initialized runtime.

Re: dmd error in wsl2

2021-05-25 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 25 May 2021 at 15:54:31 UTC, bharathyes wrote: I wrote the basic code: You have a typo in your code, `std.studio` instead of `std.stdio`.

Re: How do you compile DMD on Windows?

2021-05-01 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 1 May 2021 at 22:44:34 UTC, Blatnik wrote: They say to use the digitalmars make tool and not the normal make that I have installed. Great, no problem, except it didn't come installed with the compiler as is advertised. I don't have a make program in D/dmd2/windows/bin and I can't

Re: How do you compile DMD on Windows?

2021-05-01 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 1 May 2021 at 22:44:34 UTC, Blatnik wrote: I wanna hack on the compiler, but I've spend 3 hours and I can't get the damned thing to compile! You probably need to update the VS paths to match your local installation, Microsoft apparently changed their directory layout a few years

Re: How to skip class/function when using -HC flag to generate C++ headers?

2021-04-20 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 19 April 2021 at 17:43:34 UTC, evilrat wrote: On Monday, 19 April 2021 at 17:37:31 UTC, MoonlightSentinel wrote: Omit the modules from your blacklist when generating the header file (allthough that requires rerunning dmd) Ok thanks, well, time for new dub subconfig. Or... maybe at

Re: How to skip class/function when using -HC flag to generate C++ headers?

2021-04-19 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 19 April 2021 at 16:26:20 UTC, evilrat wrote: Or maybe there is a way to tell it whitelist/blacklist modules? The header generator only translates modules passed on the command line, other declarations are omitted unless they are required by another symbol. Omit the modules from

Re: DMD64 2.095.1 unresolved _D4core8internal7switch___T14__switch_error in optimized build only

2021-04-09 Thread MoonlightSentinel via Digitalmars-d-learn
On Friday, 9 April 2021 at 11:36:21 UTC, x3g6h7k8 wrote: The interesting point is this happens only in optimized builds. In debug builds everything is fine. Looks like DMD skips the codegen for this template instance because it erroneously assumes that the template is already emitted in

Re: Package import order with extern(C++) classes and std.container.array failure

2021-04-06 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 6 April 2021 at 09:33:32 UTC, cc wrote: Just encountered this compilation failure in DMD winx64 2.096, which previously worked in 2.095 and prior versions. DMD 2.094.2 fails with the same error? But current master works for me. Just wondering if it's a bug, or a new issue to keep

Re: Broken examples

2021-03-09 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 6 March 2021 at 09:38:54 UTC, Ali Çehreli wrote: Are you getting the same errors with those dmd versions? My locally installed compiler is dmd 2.094.2, which seems to be too old for parse's new doCount template parameter. (I look inside /usr/include/dmd/phobos/std/conv.d on my

Re: Broken examples

2021-03-09 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 6 March 2021 at 08:15:16 UTC, Imperatorn wrote: Are you sure? 樂 I tried switching to dmd-beta, dmd-nightly, ldc and ldc-beta and none of them worked. Yes. All of those were stuck at 2.093 due to some issues with Travis. We've resolved those issues over the last few days and

Re: Broken examples

2021-03-05 Thread MoonlightSentinel via Digitalmars-d-learn
On Friday, 5 March 2021 at 22:01:37 UTC, Imperatorn wrote: Any idea why? The examples are compiled using an older host compiler (__VERSION__ is 2.093) but use features introduced in a later version. This will be fixed by upgrading the compiler (the examples are checked using current master

Re: Can someone explain this?

2021-02-06 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 6 February 2021 at 14:39:38 UTC, Jeff wrote: So, I'm guessing there's something going on under-the-hood using the ~ operator with the enum and I'd like to understand what it is. Enum to string conversion is usually implemented using the name of the enum member, regardless of

Re: More elaborate asserts in unittests?

2020-10-22 Thread MoonlightSentinel via Digitalmars-d-learn
On Thursday, 22 October 2020 at 04:20:35 UTC, Mathias LANG wrote: Unfortunately this switch still has some bugs, so you can easily run into linker errors. I'm hoping to ultimately make it the default though. Which is more of a template emission problem because `-checkaction=context` uses a

Re: Template: get function name

2020-08-17 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 17 August 2020 at 09:59:21 UTC, novice3 wrote: On Monday, 17 August 2020 at 09:45:55 UTC, novice3 wrote: access violation occur. reduced code https://run.dlang.io/is/U58t9R The wrapper parameters don't inherit the storage classes from the wrapped function. Try using

Re: getopt Basic usage

2020-08-15 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 15 August 2020 at 04:09:19 UTC, James Gray wrote: I am trying to use getopt and would not like the program to throw an unhandled exception when parsing command line options. Try passing config.passThrough, it should disable the exception for unknown arguments.

Using D with PlatformIO

2020-07-31 Thread MoonlightSentinel via Digitalmars-d-learn
Currently working on a PlatformIO [1] based project in C++ and want to throw some D into the mix. Couldn't find an existing solution and I'm not sure how to implement a proper solution using PIO's scripting capabilities. Did somebody try this before and could share his experiences? [1]

Re: 2-D array initialization

2020-07-31 Thread MoonlightSentinel via Digitalmars-d-learn
On Friday, 31 July 2020 at 23:42:45 UTC, Andy Balba wrote: How does one initialize c in D ? ubyte[3][4] c = [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, 35,35] ]; none of the statements below works c = cast(ubyte) [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, 35,35] ]; This is an

Re: Why are std.bitmanip.bitfields so big ?

2020-07-28 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 28 July 2020 at 09:28:27 UTC, wjoe wrote: It was run on the doc page. I suppose the examples are wrapped in a unittest block? Indeed, see https://github.com/dlang/phobos/blob/cd2ba0d2c378a893ec0eaefc57b87d0770a1990c/std/bitmanip.d#L293-L314

Re: Finding the file and unittest that triggers an ICE during dub project build only when unittests are enabled

2020-06-15 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 15 June 2020 at 16:55:00 UTC, MoonlightSentinel wrote: And these unittests trigger the segfault: https://github.com/nordlow/phobos-next/blob/4a18833e226be0d3363fb07f02a7bcf531892e17/src/nxt/cyclic_array.d#L704-L712

Re: Finding the file and unittest that triggers an ICE during dub project build only when unittests are enabled

2020-06-15 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 15 June 2020 at 10:54:47 UTC, Per Nordlöw wrote: What have I missed? My mistake, dub dustmite expects a path to an temporary directory suitable for dustmite (it copies the entire projet + all dependencies s.t. dustmite sees the entire source code). That path needs to be somewhere

Re: Finding the file and unittest that triggers an ICE during dub project build only when unittests are enabled

2020-06-12 Thread MoonlightSentinel via Digitalmars-d-learn
On Friday, 12 June 2020 at 18:18:25 UTC, Per Nordlöw wrote: How do I most easily track down which unittest in which file that causes the crash? You could try to reduce your code using Dustmite through dub. This should do the job IIRC: dub dustmite --compiler=dmd --build=unittest

Re: Alpine support for D

2020-06-09 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 9 June 2020 at 14:23:34 UTC, Jesse Phillips wrote: I notice that in the new release for Alpine Linux it mentions support for D. Announcement: https://forum.dlang.org/thread/raue6j$1vp4$2...@digitalmars.com

Re: Should it compile?

2020-06-06 Thread MoonlightSentinel via Digitalmars-d-learn
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.

Re: Sum string lengths

2020-05-13 Thread MoonlightSentinel via Digitalmars-d-learn
On Wednesday, 13 May 2020 at 13:52:13 UTC, Andrey wrote: Hi, I want to sum lengths of all strings in array: auto data = ["qwerty", "az", ""]; Fold and reduce doesn't work: auto result = data.fold!`a + b.length`(0U); gives error: static assert: "Incompatible function/seed/element:

Re: Simple array problem

2020-04-04 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 4 April 2020 at 09:09:44 UTC, Giovanni Di Maria wrote: Why the followin code gives me the error? Error: only one index allowed to index `int[3][3]` Use matrix[2][2] instead of matrix[2,2].

Re: Linear array to matrix

2020-04-04 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 4 April 2020 at 09:25:14 UTC, Giovanni Di Maria wrote: Is there a Built-in function (no code, only a built-in function) that transform a linear array to a Matrix? You can combine slide [1] and array [2]: import std; void main() { auto input =

Re: How to code Z-Function of string?

2020-03-26 Thread MoonlightSentinel via Digitalmars-d-learn
On Thursday, 26 March 2020 at 19:34:08 UTC, Quantium wrote: string s="abc"; writeln(s[1]); // Should write 'b' or not??? Is it a legit code or it doesn't work ? Yes, but keep in mind that char[] implies UTF8. Hence this won't work if your input contains e.g. chinese characters.

Re: OR in version conditional compilation

2020-03-18 Thread MoonlightSentinel via Digitalmars-d-learn
On Wednesday, 18 March 2020 at 16:23:26 UTC, IGotD- wrote: you get the idea. So is this possible at all or do you have to duplicate the code for each version identifier despite they are equal for many version identifiers? The usual workaround is to define a common version, e.g. version(X86)

Re: static foreach / How to construct concatenated string?

2020-03-09 Thread MoonlightSentinel via Digitalmars-d-learn
On Sunday, 8 March 2020 at 20:28:01 UTC, Robert M. Münch wrote: You can get rid of the enum [...] That depends on your use case. You will need enum if you want to use the value at compile time (e.g. when using it as a template parameter). Otherwise a normal string will suffice. und the

Re: static foreach / How to construct concatenated string?

2020-03-07 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 7 March 2020 at 16:30:59 UTC, Robert M. Münch wrote: Is this possible at all? You can use an anonymous lambda to build the string in CTFE: -- struct S { int a; bool b; } import std; enum string sql = { string s = "CREATE

Re: core.atomic.atomicStore and structs

2020-03-03 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 3 March 2020 at 11:04:53 UTC, Saurabh Das wrote: PS: Any chance this will make it into DMD 2.091.0? Yes, this fix will be in the upcoming release.

Re: core.atomic.atomicStore and structs

2020-03-03 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 3 March 2020 at 09:12:40 UTC, Saurabh Das wrote: Is this supposed to not work anymore? Or is this a bug? That is a bug, see https://issues.dlang.org/show_bug.cgi?id=20629

Re: Is deprecating a template supposed to work?

2020-02-20 Thread MoonlightSentinel via Digitalmars-d-learn
On Thursday, 20 February 2020 at 22:31:16 UTC, aliak wrote: Is this suppose to give a deprecation error message? deprecated("a") alias A(T) = B!T; template B(T) { alias B = T; } void main() { A!int a; // should this cause a message "a" ? } ?? Or am I using it wrong maybe? It's a

Re: D create many thread

2020-02-05 Thread MoonlightSentinel via Digitalmars-d-learn
On Wednesday, 5 February 2020 at 13:05:59 UTC, Eko Wahyudin wrote: What is this thread for? and is it normal in D? According to the stack trace your applications triggered a GC cycle. The marking is done in parallel to minimize pause times, see https://dlang.org/spec/garbage.html

Re: digger: Failed to spawn new process (The system cannot find the file specified.)

2020-02-03 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 3 February 2020 at 20:41:00 UTC, Anonymouse wrote: It doesn't seem to include debugging symbols. Does digger not build its dmds with -g? The exceptions happens inside of build.d not dmd which wasn't built with debug informations until recently. Here's the full log:

Re: digger: Failed to spawn new process (The system cannot find the file specified.)

2020-02-03 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 3 February 2020 at 16:54:20 UTC, Anonymouse wrote: It does a `dmd.exe -of..\generated\build.exe`, but then the immediately following call to `..\generated\build.exe` fails? What am I doing wrong? The executable was launched because make would yield a different error message

Re: How do I fix my failed PRs?

2020-02-02 Thread MoonlightSentinel via Digitalmars-d-learn
On Sunday, 2 February 2020 at 16:29:34 UTC, bauss wrote: Since he just edited markdown files then it shouldn't matter. Why? The grep checks explicitly for trailing whitespace in markdown files.

Re: How do I fix my failed PRs?

2020-02-02 Thread MoonlightSentinel via Digitalmars-d-learn
On Sunday, 2 February 2020 at 08:54:02 UTC, mark wrote: However, four have not been accepted, apparently for technical reasons. But I don't understand what's wrong or what I need to do to fix them. (I'm not very knowledgeable about github.) The Travis log suggest that your PRs contain some

Re: Cannot implicitly convert expression [[0, -1, 2], [4, 11, 2]] of type int[][] to const(int[2])[]

2020-01-31 Thread MoonlightSentinel via Digitalmars-d-learn
On Friday, 31 January 2020 at 12:37:43 UTC, Adnan wrote: What's causing this? You mixed up the array lengths: const int[3][2] matA = [[0, -1, 2], [4, 11, 2]]; const int[2][3] matB = [[3, -1], [1, 2], [6, 1]]; matA is an SA containing <2> elements of type int[3]. matB is an SA containing <3>

Re: DMD won't compile re-init of variable

2020-01-30 Thread MoonlightSentinel via Digitalmars-d-learn
On Thursday, 30 January 2020 at 21:09:41 UTC, Simon wrote: Hi dlang community, I'm trying to implement a "reset" functionality which should revert all variables to the program start initial state. Example: import Graph; protected Edge[string] m_string2edge; int main() { // adding some

Re: Template Usage with Eponymous Trick

2020-01-30 Thread MoonlightSentinel via Digitalmars-d-learn
On Thursday, 30 January 2020 at 17:00:08 UTC, ShadoLight wrote: Agreed. My question though is should the 'shorthand' notation _replace_ the 'longhand' notation, or be available _in addition_ to the 'longhand' notation in the eponymous case (so the eponymous notation is just 'syntax sugar' if

Re: Template Usage with Eponymous Trick

2020-01-30 Thread MoonlightSentinel via Digitalmars-d-learn
On Thursday, 30 January 2020 at 15:14:43 UTC, ShadoLight wrote: Is there a technical reason for this limitation? Why are the 'classical' invocation style not allowed for eponymous templates as well? It seems somewhat arbitrary - note that inner/outer functions does not have this limitation -

Re: Deprecation message from phobos compiling a vibe.d app.

2020-01-30 Thread MoonlightSentinel via Digitalmars-d-learn
On Thursday, 30 January 2020 at 13:05:05 UTC, drug wrote: That's probably triggered by some constraints. I had the issue like this with Nullable: https://github.com/dlang/phobos/pull/7324 The core problem here stems from the fact that templates are always instantiated in the scope of the

Re: CT regex in AA at compile time

2020-01-07 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 7 January 2020 at 15:40:58 UTC, Taylor Hillegeist wrote: but I can't get it to work. it says its an Error: non-constant expression. I imagine this has to do with the ctRegex template or something. maybe there is a better way? Does anyone know? This issue is unrelated to ctRegex,

Re: Finding position of a value in an array

2019-12-31 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 30 December 2019 at 23:15:48 UTC, JN wrote: I also had to ask because I couldn't find it. In other languages it's named "index()", "indexOf()" or "find()". D is the only language I know which uses the "countUntil" scheme. And even so it's not obvious from the name if it's the index

Re: Some code that compiles but shouldn't

2019-12-30 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 30 December 2019 at 18:18:49 UTC, uranuz wrote: So as you see I have added a lot of enforce to test if all variables are not null. But nothing was null and the reason of segfault were unclear. What about moduleName, mod and the return value of mod.toStdJSON()? And whats the

Re: Finding position of a value in an array

2019-12-30 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 30 December 2019 at 14:30:12 UTC, Ron Tarrant wrote: I was trying to do this with an array of pointers, but I get an error (which suggests to me that I don't know what data type a pointer is): It's not a ulong? Have I forgotten so much? D disallows implicit conversion from

Re: Finding position of a value in an array

2019-12-29 Thread MoonlightSentinel via Digitalmars-d-learn
On Sunday, 29 December 2019 at 08:31:13 UTC, mipri wrote: On Sunday, 29 December 2019 at 08:26:58 UTC, Daren Scot Wilson wrote: Reading documentation... Array, Algorithms, ... maybe I've been up too late... how does one obtain the index of, say, 55 in an array like this int[] a =

Re: array of functions/delegates

2019-12-24 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 24 December 2019 at 07:37:02 UTC, Rumbu wrote: I am trying to create an array of functions inside a struct. struct S { void f1() {} void f2() {} alias Func = void function(); immutable Func[2] = [, ] } What I got: Error: non-constant expression '' Tried also with

Re: array of functions/delegates

2019-12-24 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 24 December 2019 at 13:13:12 UTC, MoonlightSentinel wrote: On Tuesday, 24 December 2019 at 10:40:16 UTC, Mike Parker wrote: struct S {} void f1(S s) {} void f2(S s) {} alias Func = immutable(void function()); immutable Func[2] funcs = [cast(Func), cast(Func)]; Though, it's not

Re: array of functions/delegates

2019-12-24 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 24 December 2019 at 10:40:16 UTC, Mike Parker wrote: struct S {} void f1(S s) {} void f2(S s) {} alias Func = immutable(void function()); immutable Func[2] funcs = [cast(Func), cast(Func)]; Though, it's not clear to me wy the one requires casting the pointer type and the other