Re: How to work with long paths on Windows?

2022-11-13 Thread Preetpal via Digitalmars-d-learn
In case anyone wants to see a working example of how to use long paths on Windows, I uploaded a [gist](https://gist.github.com/preetpalS/2fd6c6bf05a94734f89b70b679716bf3) (see my comment in the gist for how to make it work). It is an upgraded version of the original command line tool shown in the

Re: Sorted Array (Container) Type

2022-11-13 Thread Tejas via Digitalmars-d-learn
On Sunday, 13 November 2022 at 18:51:09 UTC, Siarhei Siamashka wrote: On Saturday, 12 November 2022 at 14:07:46 UTC, Per Nordlöw wrote: Have anybody created a wrapper container ```d struct Sorted(ArrayLike, alias lessThanPred) ``` that wraps an array-like type `ArrayLike` so that it's always

Hipreme's #6 Tip of the day - Knowing when and how to use dub's Have_version

2022-11-13 Thread Hipreme via Digitalmars-d-learn
Although I really don't like many things about how dub does, it brings many facilities. Imagine the following project structure: Project A is using library B Now, imagine that our `module b` has the following code: ```d module b; void print(string s){imported!"std.stdio".writeln(s);} else ve

Re: Proper way to exit with specific exit code?

2022-11-13 Thread Ruby The Roobster via Digitalmars-d-learn
On Sunday, 13 November 2022 at 21:16:32 UTC, mw wrote: On Saturday, 19 September 2020 at 06:11:15 UTC, Jacob Carlborg wrote: On 2020-09-17 16:58, drathier wrote: What's the proper way to exit with a specific exit code? I found a bunch of old threads discussing this, making sure destructors ru

Re: Proper way to exit with specific exit code?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 22:42:45 UTC, mw wrote: On Sunday, 13 November 2022 at 22:17:32 UTC, mw wrote: On Sunday, 13 November 2022 at 22:06:09 UTC, Imperatorn wrote: On Sunday, 13 November 2022 at 21:37:47 UTC, mw wrote: On Sunday, 13 November 2022 at 21:16:32 UTC, mw wrote: I even tr

Re: Proper way to exit with specific exit code?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 22:17:32 UTC, mw wrote: On Sunday, 13 November 2022 at 22:06:09 UTC, Imperatorn wrote: On Sunday, 13 November 2022 at 21:37:47 UTC, mw wrote: On Sunday, 13 November 2022 at 21:16:32 UTC, mw wrote: I even tried core.stdc.stdlib.exit(-1), it does not work. Tried

Re: Proper way to exit with specific exit code?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 22:06:09 UTC, Imperatorn wrote: On Sunday, 13 November 2022 at 21:37:47 UTC, mw wrote: On Sunday, 13 November 2022 at 21:16:32 UTC, mw wrote: I even tried core.stdc.stdlib.exit(-1), it does not work. Tried ``` import core.runtime; Runtime.terminate(); cor

Re: Proper way to exit with specific exit code?

2022-11-13 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 13 November 2022 at 21:37:47 UTC, mw wrote: On Sunday, 13 November 2022 at 21:16:32 UTC, mw wrote: I even tried core.stdc.stdlib.exit(-1), it does not work. Tried ``` import core.runtime; Runtime.terminate(); core.stdc.stdlib.exit(-1); ``` Still does not work. I have no id

Re: Proper way to exit with specific exit code?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 21:16:32 UTC, mw wrote: I even tried core.stdc.stdlib.exit(-1), it does not work. Tried ``` import core.runtime; Runtime.terminate(); core.stdc.stdlib.exit(-1); ``` Still does not work.

Re: does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:02:29 UTC, mw wrote: BTW, can --build=profile-gc can intercept "Ctrl+C" and generate *partial* report file? And what's the suggested proper way to do Is there a profile-gc plugin function I can call in the middle of my program to generate *partial* report fi

Re: Proper way to exit with specific exit code?

2022-11-13 Thread mw via Digitalmars-d-learn
On Saturday, 19 September 2020 at 06:11:15 UTC, Jacob Carlborg wrote: On 2020-09-17 16:58, drathier wrote: What's the proper way to exit with a specific exit code? I found a bunch of old threads discussing this, making sure destructors run and the runtime terminates properly, all of which see

Re: Making sense out of scope and function calls

2022-11-13 Thread 0xEAB via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:36:48 UTC, Dennis wrote: Can you please provide a full example? I'm missing the definitions of _headers, hstring, values ```d /++ “HTTP message string” – short-hand for `const(char)[]``. $(SIDEBAR Not sure about the name. Would have pre

Re: Making sense out of scope and function calls

2022-11-13 Thread Dennis via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:06:40 UTC, 0xEAB wrote: Why does only the latter sample compile? The former leads to the following warning: Can you please provide a full example? I'm missing the definitions of _headers, hstring, values, and I suspect there's at least one `@safe` annotation

Re: Making sense out of scope and function calls

2022-11-13 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:06:40 UTC, 0xEAB wrote: ```d struct Foo { /* … */ hstring[] getHeader(LowerCaseToken name) scope return { return _headers[name].values; } [...] There's an old saying "you can't make sense out of scope"

Making sense out of scope and function calls

2022-11-13 Thread 0xEAB via Digitalmars-d-learn
```d struct Foo { /* … */ hstring[] getHeader(LowerCaseToken name) scope return { return _headers[name].values; } hstring[] getHeader(hstring name)() scope return { enum token = LowerCaseToken.makeConverted(name); return this.getHeader(token); // line 6

Re: does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 18:51:17 UTC, mw wrote: On Sunday, 13 November 2022 at 18:48:42 UTC, mw wrote: BTW, can --build=profile-gc can intercept "Ctrl+C" and generate *partial* report file? And what's the suggested proper way to do early exit, and still let --build=profile-gc generate

Re: does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 18:48:42 UTC, mw wrote: BTW, can --build=profile-gc can intercept "Ctrl+C" and generate *partial* report file? And what's the suggested proper way to do early exit, and still let --build=profile-gc generate reports? I tried presss "Ctrl+C", and that cannot stop

Re: Sorted Array (Container) Type

2022-11-13 Thread Siarhei Siamashka via Digitalmars-d-learn
On Saturday, 12 November 2022 at 14:07:46 UTC, Per Nordlöw wrote: Have anybody created a wrapper container ```d struct Sorted(ArrayLike, alias lessThanPred) ``` that wraps an array-like type `ArrayLike` so that it's always sorted according to the binary predicate `lessThanPred`? I'm not sur

does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn
Hi, I'm mem-profiling a multi-threaded program, and want it to exit early, so I added a call ``` core.stdc.stdlib.exit(-1); ``` in a loop in one of the thread. However when the program reached this point, it seems hang: it's not exiting, and CPU usage dropped to 0%. I'm wondering does dmd

Re: Comparison of two 'dynamic arrays'.

2022-11-13 Thread matheus. via Digitalmars-d-learn
On Sunday, 13 November 2022 at 17:10:23 UTC, DLearner wrote: ... The slight generalisation shown at bottom also worked. However, is there a way of avoiding the for-loop? ... I don't have too much knowledge in D, but I think so. (My main language is C). Well, one way to make things "better"

Re: Comparison of two 'dynamic arrays'.

2022-11-13 Thread DLearner via Digitalmars-d-learn
On Sunday, 13 November 2022 at 16:11:17 UTC, matheus. wrote: [...] You should add the code below after "auto B = A.dup;": B[0].Txt = A[0].Txt.dup; The "Txt" property inside B is still referencing A without the above. Matheus. Thank you - your suggestion worked. The slight generalisati

Re: Comparison of two 'dynamic arrays'.

2022-11-13 Thread Siarhei Siamashka via Digitalmars-d-learn
On Sunday, 13 November 2022 at 15:45:40 UTC, DLearner wrote: ```D struct test_struct { char[] Txt; } test_struct[] A; auto B = A.dup; ``` But A is not an `int[]` in your new example. You need a "deep copy" and I can see that similar questions had been asked in this forum bef

Re: Comparison of two 'dynamic arrays'.

2022-11-13 Thread matheus. via Digitalmars-d-learn
On Sunday, 13 November 2022 at 15:45:40 UTC, DLearner wrote: On Sunday, 13 November 2022 at 14:39:26 UTC, Siarhei Siamashka wrote: On Sunday, 13 November 2022 at 14:28:45 UTC, DLearner wrote: Creating a step 1.5: ``` int[] B = A; ``` ```D auto B = A.dup; ``` This will create a copy of A rath

Re: Comparison of two 'dynamic arrays'.

2022-11-13 Thread DLearner via Digitalmars-d-learn
On Sunday, 13 November 2022 at 14:39:26 UTC, Siarhei Siamashka wrote: On Sunday, 13 November 2022 at 14:28:45 UTC, DLearner wrote: Creating a step 1.5: ``` int[] B = A; ``` ```D auto B = A.dup; ``` This will create a copy of A rather than referencing to the same buffer in memory. Tested:

Re: Comparison of two 'dynamic arrays'.

2022-11-13 Thread Siarhei Siamashka via Digitalmars-d-learn
On Sunday, 13 November 2022 at 14:28:45 UTC, DLearner wrote: Creating a step 1.5: ``` int[] B = A; ``` ```D auto B = A.dup; ``` This will create a copy of A rather than referencing to the same buffer in memory.

Comparison of two 'dynamic arrays'.

2022-11-13 Thread DLearner via Digitalmars-d-learn
Hi Program has two steps: 1. Creates an array (int[] A), whose size and element values are only known at run-time. Then: 2. The elements (but not the array size) are further processed in a way that may or may not alter their value. Requirement: to identify the indices (if any) of the elemen

Re: ImportC linking issue

2022-11-13 Thread Andrey Zherikov via Digitalmars-d-learn
On Saturday, 12 November 2022 at 10:02:12 UTC, confuzzled wrote: Why would I have to search for libcrypto, libminizip, libexpat, and more that I haven't even figured out what library they are? I thought those dependencies would already be linked into libxlsxio_read.a which is a statically linke

Re: Using glibc headers with ImportC

2022-11-13 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 13 November 2022 at 09:15:39 UTC, qua wrote: I agree it was unexpected that it didn't, at least for newcomers. Almost everyone is a newcomer when it comes to ImportC.

Re: Using glibc headers with ImportC

2022-11-13 Thread qua via Digitalmars-d-learn
On Saturday, 12 November 2022 at 14:14:06 UTC, Adam D Ruppe wrote: On Saturday, 12 November 2022 at 13:46:27 UTC, qua wrote: This is supposed to work, right? No, it isn't. And it probably never will. importC looks for a .c file in the current directory. It is that .c file's responsibility to