getopt Basic usage

2020-08-14 Thread James Gray via Digitalmars-d-learn
I am trying to use getopt and would not like the program to throw an unhandled exception when parsing command line options. Is the following, adapted from the first example in the getopt documentation, a reasonable approach? import std.getopt; string data = "file.dat"; int length = 24; bool

Alternative to std.range.choose

2020-07-21 Thread James Gray via Digitalmars-d-learn
Is there a better way to achieve behaviour similar to rangeFuncIf below? f gives a contrived example of when one might want this. g is how one might try and achieve the same with std.range.choose. import std.stdio; import std.range : only, chain, join, choose; import std.algorithm : map; auto

Re: Alternative to std.range.choose

2020-07-22 Thread James Gray via Digitalmars-d-learn
On Wednesday, 22 July 2020 at 06:16:44 UTC, WebFreak001 wrote: On Wednesday, 22 July 2020 at 04:33:20 UTC, James Gray wrote: [...] it seems `choose` evaluates both arguments instead of using lazy evaluation. IMO this is a broken API to me but it has been like this for longer so this would

Re: Garbage collection

2020-06-27 Thread James Gray via Digitalmars-d-learn
On Saturday, 27 June 2020 at 11:00:58 UTC, Stanislav Blinov wrote: On Saturday, 27 June 2020 at 10:08:15 UTC, James Gray wrote: I find that the memory usage grows to about 1.5GB and never decreases. Is there something I am not understanding? How are you measuring that? GC.collect() does not

Re: Garbage collection

2020-06-27 Thread James Gray via Digitalmars-d-learn
On Saturday, 27 June 2020 at 10:08:15 UTC, James Gray wrote: I am writing a web application using vibe.d (not sure whether that is relevant or not), and have run into a memory leak. I wrote the following code to try and replicate the problem. [...] I now compiled the same code above with

Re: Garbage collection

2020-06-27 Thread James Gray via Digitalmars-d-learn
On Saturday, 27 June 2020 at 14:12:09 UTC, kinke wrote: On Saturday, 27 June 2020 at 10:08:15 UTC, James Gray wrote: have run into a memory leak Something seems really off indeed. I've run this on Win64 with DMD (2.092) and LDC (1.22), without any extra cmdline options: - import

Garbage collection

2020-06-27 Thread James Gray via Digitalmars-d-learn
I am writing a web application using vibe.d (not sure whether that is relevant or not), and have run into a memory leak. I wrote the following code to try and replicate the problem. import std.algorithm; import std.range; import std.format; import std.stdio; import core.thread; import

Re: Garbage collection

2020-06-27 Thread James Gray via Digitalmars-d-learn
On Saturday, 27 June 2020 at 12:07:19 UTC, Stanislav Blinov wrote: On Saturday, 27 June 2020 at 11:35:12 UTC, Arafel wrote: If you are using linux, have in mind that the memory is often not returned to the OS even after a (libc) free. That's a good observation. Although a GC implementation

Re: Garbage collection

2020-06-27 Thread James Gray via Digitalmars-d-learn
On Saturday, 27 June 2020 at 12:53:01 UTC, James Gray wrote: On Saturday, 27 June 2020 at 12:07:19 UTC, Stanislav Blinov wrote: On Saturday, 27 June 2020 at 11:35:12 UTC, Arafel wrote: [...] That's a good observation. Although a GC implementation is not required to actually use malloc, so

Re: Garbage collection

2020-06-27 Thread James Gray via Digitalmars-d-learn
On Saturday, 27 June 2020 at 14:49:34 UTC, James Gray wrote: On Saturday, 27 June 2020 at 14:12:09 UTC, kinke wrote: [...] Thank you for doing this. I hope my example doesn't obscure what you show here. (I borrowed some of your code). [...] In case it helps, setting all the next and

Re: Garbage collection

2020-07-20 Thread James Gray via Digitalmars-d-learn
On Tuesday, 30 June 2020 at 06:16:26 UTC, Kagamin wrote: On Saturday, 27 June 2020 at 14:49:34 UTC, James Gray wrote: I have produced something which essentially reproduces my problem. What is the problem? Do you have a leak or you want to know how GC works? I have managed to resolve my

Re: getopt Basic usage

2020-08-15 Thread James Gray via Digitalmars-d-learn
On Saturday, 15 August 2020 at 04:39:58 UTC, mw wrote: 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. Is the following, adapted from the first example in

Re: getopt Basic usage

2020-08-15 Thread James Gray via Digitalmars-d-learn
On Saturday, 15 August 2020 at 09:48:26 UTC, MoonlightSentinel wrote: 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

Re: getopt Basic usage

2020-08-15 Thread James Gray via Digitalmars-d-learn
On Saturday, 15 August 2020 at 17:04:17 UTC, Jon Degenhardt wrote: 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. Is the following, adapted from the first