Re: why local variables cannot be ref?

2019-11-24 Thread Rumbu via Digitalmars-d-learn
On Monday, 25 November 2019 at 03:07:08 UTC, Fanda Vacek wrote: Maybe I'm missing the thing, but I'm not able to declare local ref variable even if simple workaround exists. Is this preferred design pattern? ``` int main() { int a = 1; //ref int b = a; // Error: variable

why local variables cannot be ref?

2019-11-24 Thread Fanda Vacek via Digitalmars-d-learn
Maybe I'm missing the thing, but I'm not able to declare local ref variable even if simple workaround exists. Is this preferred design pattern? ``` int main() { int a = 1; //ref int b = a; // Error: variable `tst_ref.main.b` only parameters or `foreach` declarations can be `ref`

Re: Leak-detection of references to scoped class instances

2019-11-24 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 24 November 2019 at 14:21:48 UTC, Adam D. Ruppe wrote: On Sunday, 24 November 2019 at 14:19:23 UTC, Per Nordlöw wrote: Why doesn't DIP-1000 include such escape analysis? did you enable it with the command line switch? furthermore i *think* it onyl works o @safe stuff, not @trusted

Re: dmd memory usage

2019-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/24/19 10:34 AM, Jacob Carlborg wrote: On 2019-11-18 01:20, Steven Schveighoffer wrote: I'm fighting some out of memory problems using DMD and some super-template heavy code. I have ideas on how to improve the situation, but it involves redesigning a large portion of the design. I want

Re: How to wait for a shell process to finish on ctrl+c before exiting?

2019-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/24/19 10:44 AM, aliak wrote: I'm writing some command line tooling stuff, and one of the command spins up a docker compose file (which in short, spins up some services and aggregates the output of each service to stdout). When a user presses ctrl+c, i would like to pass on the ctrl+c to

Re: Spawning a process, then killing it on SIGINT

2019-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/24/19 10:36 AM, aliak wrote: On Saturday, 23 November 2019 at 12:19:27 UTC, Steven Schveighoffer wrote: On 11/23/19 4:54 AM, aliak wrote: Is there a way to go about killing a process after spawning it on a SIGINT? I can't do this for e.g. because kill is not @nogc. Pid

Re: How to wait for a shell process to finish on ctrl+c before exiting?

2019-11-24 Thread mipri via Digitalmars-d-learn
On Sunday, 24 November 2019 at 15:44:00 UTC, aliak wrote: I'm writing some command line tooling stuff, and one of the command spins up a docker compose file (which in short, spins up some services and aggregates the output of each service to stdout). When a user presses ctrl+c, i would like

How to wait for a shell process to finish on ctrl+c before exiting?

2019-11-24 Thread aliak via Digitalmars-d-learn
I'm writing some command line tooling stuff, and one of the command spins up a docker compose file (which in short, spins up some services and aggregates the output of each service to stdout). When a user presses ctrl+c, i would like to pass on the ctrl+c to the spawned process and wait till

Re: Spawning a process, then killing it on SIGINT

2019-11-24 Thread aliak via Digitalmars-d-learn
On Saturday, 23 November 2019 at 12:19:27 UTC, Steven Schveighoffer wrote: On 11/23/19 4:54 AM, aliak wrote: Is there a way to go about killing a process after spawning it on a SIGINT? I can't do this for e.g. because kill is not @nogc. Pid currentSpawnedPid; extern(C) void

Re: dmd memory usage

2019-11-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-11-18 01:20, Steven Schveighoffer wrote: I'm fighting some out of memory problems using DMD and some super-template heavy code. I have ideas on how to improve the situation, but it involves redesigning a large portion of the design. I want to do it incrementally, but I need to see

Re: Spawning a process, then killing it on SIGINT

2019-11-24 Thread aliak via Digitalmars-d-learn
On Saturday, 23 November 2019 at 10:09:51 UTC, mipri wrote: On Saturday, 23 November 2019 at 09:54:48 UTC, aliak wrote: Is there a way to go about killing a process after spawning it on a SIGINT? I can't do this for e.g. because kill is not @nogc. Well, this works: import std; import

Re: Leak-detection of references to scoped class instances

2019-11-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 24 November 2019 at 14:19:23 UTC, Per Nordlöw wrote: Why doesn't DIP-1000 include such escape analysis? did you enable it with the command line switch? furthermore i *think* it onyl works o @safe stuff, not @trusted stuff.

Re: Leak-detection of references to scoped class instances

2019-11-24 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 24 November 2019 at 12:51:53 UTC, rikki cattermole wrote: "Allocates a class object right inside the current scope, therefore avoiding the overhead of new. This facility is unsafe; it is the responsibility of the user to not escape a reference to the object outside the scope."

Re: Leak-detection of references to scoped class instances

2019-11-24 Thread rikki cattermole via Digitalmars-d-learn
"Allocates a class object right inside the current scope, therefore avoiding the overhead of new. This facility is unsafe; it is the responsibility of the user to not escape a reference to the object outside the scope." https://dlang.org/phobos/std_typecons.html#.scoped

Leak-detection of references to scoped class instances

2019-11-24 Thread Per Nordlöw via Digitalmars-d-learn
Why doesn't DMD detect invalid out-of-scope references to scoped class instances? Example: @safe: class C { @safe pure: this() { } int x; } @trusted unittest { C f() { import std.typecons : scoped; auto x = scoped!C(); return x; } auto