Re: Non-blocking reads of a fifo (named pipe)?

2018-12-03 Thread Basile B. via Digitalmars-d-learn
On Monday, 3 December 2018 at 23:32:10 UTC, Anonymouse wrote: I have a fifo that I want to read lines from, but everything is blocking. [...] How can I go about doing this to get non-blocking reads? Or perhaps a way to test whether there is text waiting in the fifo? File.eof is not it. [...]

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-12-03 Thread Timon Gehr via Digitalmars-d-learn
On 22.11.18 16:19, Steven Schveighoffer wrote: In terms of language semantics, I don't know what the right answer is. If we want to say that if an optimizer changes program behavior, the code must be UB, then this would have to be UB. But I would prefer saying something like -- if a

Re: Initialize static array without explicit length

2018-12-03 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 3 December 2018 at 09:51:45 UTC, Andrey wrote: Hi, I want to create a static array and immediately init it with values: uint[x] data = [1,3,10,44,0,5000]; I don't want to set the length of it explicitly (x in square brackets). I want that compiler itself counted number of

Re: Initialize static array without explicit length

2018-12-03 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 3 December 2018 at 12:19:26 UTC, Dennis wrote: On Monday, 3 December 2018 at 10:00:31 UTC, Simen Kjærås wrote: However, it's easy to implement in a library: It even is in phobos: https://dlang.org/phobos/std_array.html#.staticArray ``` import std.array: staticArray; auto a = [0,

Re: Initialize static array without explicit length

2018-12-03 Thread Dennis via Digitalmars-d-learn
On Monday, 3 December 2018 at 10:00:31 UTC, Simen Kjærås wrote: However, it's easy to implement in a library: It even is in phobos: https://dlang.org/phobos/std_array.html#.staticArray ``` import std.array: staticArray; auto a = [0, 1, 2].staticArray; ```

Re: File .. byLine

2018-12-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/3/18 2:03 AM, Joel wrote: On Monday, 3 December 2018 at 06:55:50 UTC, Nicholas Wilson wrote: On Monday, 3 December 2018 at 06:09:21 UTC, Joel wrote: [...] https://run.dlang.io/is/h0ArAB works for me. If you want it as a string not  char[] then byLineCopy should work, if not just

Initialize static array without explicit length

2018-12-03 Thread Andrey via Digitalmars-d-learn
Hi, I want to create a static array and immediately init it with values: uint[x] data = [1,3,10,44,0,5000]; I don't want to set the length of it explicitly (x in square brackets). I want that compiler itself counted number of values (in example it is 6). What should be a right

Re: .dup vs operation on all elements

2018-12-03 Thread faissaloo via Digitalmars-d-learn
On Monday, 3 December 2018 at 20:37:22 UTC, Jonathan M Davis wrote: On Monday, December 3, 2018 1:07:24 PM MST Goksan via Digitalmars-d-learn wrote: Are there any differences between these 2 methods of copying elements? double[] array = [ 1, 20, 2, 30, 7, 11 ]; // Non dup double[6]

Re: .dup vs operation on all elements

2018-12-03 Thread Daniel Kozak via Digitalmars-d-learn
Yes it is. The dup version just make an extra copy of array for no reason. po 3. 12. 2018 21:10 odesílatel Goksan via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> napsal: > Are there any differences between these 2 methods of copying > elements? > > double[] array = [ 1, 20, 2, 30,

.dup vs operation on all elements

2018-12-03 Thread Goksan via Digitalmars-d-learn
Are there any differences between these 2 methods of copying elements? double[] array = [ 1, 20, 2, 30, 7, 11 ]; // Non dup double[6] bracket_syntax_dup = array; bracket_syntax_dup[] = array; bracket_syntax_dup[0] = 50; // Dup double[6] normal_dup = array.dup; normal_dup[0] = 100; OUTPUT:

Re: .dup vs operation on all elements

2018-12-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 3, 2018 1:07:24 PM MST Goksan via Digitalmars-d-learn wrote: > Are there any differences between these 2 methods of copying > elements? > > double[] array = [ 1, 20, 2, 30, 7, 11 ]; > > // Non dup > double[6] bracket_syntax_dup = array; > bracket_syntax_dup[] = array; >

Non-blocking reads of a fifo (named pipe)?

2018-12-03 Thread Anonymouse via Digitalmars-d-learn
I have a fifo that I want to read lines from, but everything is blocking. execute([ "mkfifo", filename ]); File fifo = File(filename, "r"); // blocks already immutable input = fifo.readln(); // blocks foreach (line; fifo.byLineCopy) { /* blocks */ } How can I go about doing this to get

Re: Non-blocking reads of a fifo (named pipe)?

2018-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 03, 2018 at 11:32:10PM +, Anonymouse via Digitalmars-d-learn wrote: > I have a fifo that I want to read lines from, but everything is > blocking. > > execute([ "mkfifo", filename ]); > File fifo = File(filename, "r"); // blocks already > immutable input = fifo.readln(); //

Re: .dup vs operation on all elements

2018-12-03 Thread Neia Neutuladh via Digitalmars-d-learn
On Mon, 03 Dec 2018 21:27:52 +, faissaloo wrote: > Then shouldn't the following output false, false, true? An object reference is a pointer value. The pointer values are copied. The pointed-at objects are not copied. Furthermore, the syntax Object[6] array = new Object(); only

Re: .dup vs operation on all elements

2018-12-03 Thread Goksan via Digitalmars-d-learn
On Monday, 3 December 2018 at 22:04:25 UTC, Neia Neutuladh wrote: On Mon, 03 Dec 2018 21:27:52 +, faissaloo wrote: Then shouldn't the following output false, false, true? An object reference is a pointer value. The pointer values are copied. The pointed-at objects are not copied.