Re: Mimicking a shell

2019-12-29 Thread angel via Digitalmars-d-learn
On Sunday, 29 December 2019 at 17:03:14 UTC, Jan wrote: Hi, Is there a way to forward all input and output from a shell? This implies that e.g. pressing the left arrow on the keyboard is immediately being forwarded to the shell and that the output from a shell would be *exactly* the same as

Re: What is the point of a synchronized lock on a single return statement?

2019-11-25 Thread angel via Digitalmars-d-learn
On Monday, 25 November 2019 at 08:22:17 UTC, Andrej Mitrovic wrote: From: https://github.com/dlang/phobos/blob/10b9174ddcadac52f6a1ea532deab3310d3a8c03/std/concurrency.d#L1913-L1916: - /// final @property bool isClosed() @safe @nogc pure { synchronized (m_lock) { return

Re: gtkDcoding Facelift

2019-06-23 Thread angel via Digitalmars-d-learn
On Sunday, 23 June 2019 at 10:55:52 UTC, Ron Tarrant wrote: Stage 1 is now complete. Blog entries are color-associated in an effort to make things more visual. Each topic also has its own avatar. Points to anyone who can figure out why each avatar is associated with its topic.

Re: Singleton in Action?

2019-02-02 Thread angel via Digitalmars-d-learn
On Saturday, 2 February 2019 at 19:23:58 UTC, Ron Tarrant wrote: Thanks for the replies, fellow programmers. (generic, unisex, PC, and all-encompassing) If I could trouble someone for a complete working example so I have something to study, that would be excellent. I think that's what you

Re: Reverse and sort array elements

2018-12-18 Thread angel via Digitalmars-d-learn
On Tuesday, 18 December 2018 at 12:07:37 UTC, Andrey wrote: Hi, Have array: enum array = ["qwerty", "a", "baz"]; Need to reverse and sort array elements to get this result: [a, ytrewq, zab] Did this: enum result = array.map!(value => value.retro()).sort(); Got: Error: template

Re: How to list all process directories under /proc/

2017-09-22 Thread angel via Digitalmars-d-learn
On Sunday, 17 September 2017 at 08:15:58 UTC, Ky-Anh Huynh wrote: Hi, I want to list all processes by scanning /proc/. The following code doesn't work [code] foreach (string fstatm; dirEntries("/proc/", "[0-9]*", SpanMode.shallow)) { writefln("pid %s", fstatm); } [/code] as it

Re: real simple delegate question.

2017-08-20 Thread angel via Digitalmars-d-learn
On Saturday, 19 August 2017 at 18:33:37 UTC, WhatMeWorry wrote: On Friday, 18 August 2017 at 20:39:38 UTC, angel wrote: On Friday, 18 August 2017 at 02:38:15 UTC, WhatMeForget wrote: [...] This actually appears correct ... The 1-st example: Each call to makeCalculator() increments a static

Re: real simple delegate question.

2017-08-18 Thread angel via Digitalmars-d-learn
On Friday, 18 August 2017 at 02:38:15 UTC, WhatMeForget wrote: Can someone explain what is the difference between the two? Thanks. module gates; import std.stdio; import std.random; alias Calculator = int delegate(int); Calculator makeCalculator() { static int context = 0; int

Re: Create class on stack

2017-08-05 Thread angel via Digitalmars-d-learn
On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since I'm using it in a delegate I would like

Re: Factory using an alias template parameter to set a member of the new tool ?

2017-02-09 Thread angel via Digitalmars-d-learn
On Thursday, 9 February 2017 at 14:39:41 UTC, angel wrote: On Thursday, 9 February 2017 at 13:30:07 UTC, jkpl wrote: I'm looking for a better way to do this, if possible: ``` class Tool { string name; } T namedTool(alias Variable, T)() { T result = new T; result.name =

Re: Factory using an alias template parameter to set a member of the new tool ?

2017-02-09 Thread angel via Digitalmars-d-learn
On Thursday, 9 February 2017 at 13:30:07 UTC, jkpl wrote: I'm looking for a better way to do this, if possible: ``` class Tool { string name; } T namedTool(alias Variable, T)() { T result = new T; result.name = Variable.stringof; return result; } void main() { Tool grep;

Re: capture stdout or stderr

2017-02-01 Thread angel via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 01:08:19 UTC, Emil wrote: is it possible to intercept the STDOUT or STDERR and capture the output into a variable ? some pseudocode to explain what I mean string[] output_buffer; stdout.capture_to(output_buffer); writeln("test 1"); # not printed

Re: @property get/set or public varaible?

2016-12-04 Thread angel via Digitalmars-d-learn
On Sunday, 4 December 2016 at 15:30:22 UTC, vladdeSV wrote: Hello! I have a question not directly related to D as it is with coding standards. My issue at hand is if I have one variable for a class, which I want to be directly accessible for anything else, should it be 1. public, or 2.

Re: spawnProcess() not child?

2014-11-03 Thread angel via Digitalmars-d-learn
The parent / child relationship always exists. In POSIX OSs, you may ignore SIGCHLD signal (announcing child process death), so that in case of child process exit it will not become zombie, rather it will be disposed on the spot. As a side note, in Linux, there exist a system call allowing