Re: Spawning a process: Can I "have my cake and eat it too"?

2018-03-01 Thread Vladimir Panteleev via Digitalmars-d-learn
On Friday, 2 March 2018 at 04:50:06 UTC, Nick Sabalausky (Abscissa) wrote: Launch a process (spawnProcess, pipeShell, etc) so the child's stdout/stderr go to the parent's stdout/stderr *without* the possibility of them getting inadvertently reordered/reinterleaved when viewed on the terminal, *

Re: Spawning a process: Can I "have my cake and eat it too"?

2018-03-01 Thread Adam D. Ruppe via Digitalmars-d-learn
I would suggest redirecting the child to the parent pipe, but then having the parent write the data back out to its own stdout/err. It'd be a bit tricky with just Phobos' file though because it doesn't make it easy to wait for or be notified about input on it, but the underlying OS apis make

Spawning a process: Can I "have my cake and eat it too"?

2018-03-01 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
I'd like to include this functionality in Scriptlike, but I don't know if it's even possible: Launch a process (spawnProcess, pipeShell, etc) so the child's stdout/stderr go to the parent's stdout/stderr *without* the possibility of them getting inadvertently reordered/reinterleaved when viewe

Re: Assigning to slice of array

2018-03-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 01, 2018 23:51:37 Jamie via Digitalmars-d-learn wrote: > On a similar not, is there an accepted way to assign across > arrays? As Steve mentioned, cross-slicing isn't supported, so is > the best way to iterate through the array and assign as necessary? That's what you would have

Re: Assigning to slice of array

2018-03-01 Thread Jamie via Digitalmars-d-learn
On Thursday, 1 March 2018 at 23:17:11 UTC, Jonathan M Davis wrote: So, something like auto arr = new int[][][](3, 2, 1); arr.length = 4; arr[0].length = 5; arr[0][0].length = 6; is legal, but something like Thanks Jonathan, this is exactly what I was looking for. I was getting confused with

Re: Assigning to slice of array

2018-03-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 01, 2018 22:57:16 Jamie via Digitalmars-d-learn wrote: > On Thursday, 1 March 2018 at 21:34:41 UTC, Jonathan M Davis wrote: > > Don't put the indices within the brackets. What you want is > > > > auto arr = new int[][][](3, 2, 1); > > Okay thanks, but I don't understand what is t

Re: Assigning to slice of array

2018-03-01 Thread Jamie via Digitalmars-d-learn
On Thursday, 1 March 2018 at 21:34:41 UTC, Jonathan M Davis wrote: Don't put the indices within the brackets. What you want is auto arr = new int[][][](3, 2, 1); Okay thanks, but I don't understand what is the issue with having static arrays there instead? My functionality didn't change when

Re: Assigning to slice of array

2018-03-01 Thread ag0aep6g via Digitalmars-d-learn
On 03/01/2018 11:43 PM, Jamie wrote: So if I do     arr[0 .. 1][0] = 3; shouldn't this return     [[3, 0, 0], [0, 0, 0]] ? Because I'm taking the slice arr[0 .. 1], or arr[0], which is the first [0, 0, 0]? arr[0 .. 1] is not the same as arr[0]. arr[0 .. 1] is not the first element of arr; i

Re: Assigning to slice of array

2018-03-01 Thread Jamie via Digitalmars-d-learn
On Thursday, 1 March 2018 at 21:31:49 UTC, Steven Schveighoffer wrote: No, I think you did int[3][2], if you got that output. Otherwise it would have been: [[[0,0,0],[0,0,0]]] Yes apologies that was there from a previous attempt, you are correct. Well, that's because that type of slicing i

Re: Assigning to slice of array

2018-03-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/1/18 4:16 PM, Jamie wrote: I'm trying to understand arrays and have read a lot of the information about them on this forum. I think I understand that they are set-up like Type[], so that int[][] actually means an array of int[]. I create an array as per the following:     auto arr = new

Re: Assigning to slice of array

2018-03-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 01, 2018 21:16:54 Jamie via Digitalmars-d-learn wrote: > I'm trying to understand arrays and have read a lot of the > information about them on this forum. I think I understand that > they are set-up like Type[], so that int[][] actually means an > array of int[]. > > I create an

Assigning to slice of array

2018-03-01 Thread Jamie via Digitalmars-d-learn
I'm trying to understand arrays and have read a lot of the information about them on this forum. I think I understand that they are set-up like Type[], so that int[][] actually means an array of int[]. I create an array as per the following: auto arr = new int[3][2][1]; which produces:

Re: Garbage collected pointers?

2018-03-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 01, 2018 15:53:08 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 3/1/18 3:33 PM, H. S. Teoh wrote: > > Won't a precise GC scanning for pointers to aligned objects want to skip > > values that can't be an aligned pointer? Though in D's case, being > > required to be co

Re: Garbage collected pointers?

2018-03-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/1/18 3:33 PM, H. S. Teoh wrote: On Thu, Mar 01, 2018 at 02:52:26PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] There are a few in there, which I think are over-the-top. Such as "don't cast a pointer to a non-pointer", [...] Isn't that necessary for a precise GC? It

Re: Garbage collected pointers?

2018-03-01 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 01, 2018 at 02:52:26PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] > There are a few in there, which I think are over-the-top. Such as > "don't cast a pointer to a non-pointer", [...] Isn't that necessary for a precise GC? Also, AIUI the current GC already does n

Re: Garbage collected pointers?

2018-03-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 01, 2018 14:52:26 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 3/1/18 2:04 PM, Jonathan M Davis wrote: > > On Thursday, March 01, 2018 10:55:34 Steven Schveighoffer via > > Digitalmars-d-> > > learn wrote: > >> It should really say that it's up to the GC implementati

Re: Garbage collected pointers?

2018-03-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/1/18 2:04 PM, Jonathan M Davis wrote: On Thursday, March 01, 2018 10:55:34 Steven Schveighoffer via Digitalmars-d- learn wrote: It should really say that it's up to the GC implementation whether it's UB or not. Well, that arguably makes it UB in general then, because it can't be relied on

Re: Garbage collected pointers?

2018-03-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 01, 2018 10:55:34 Steven Schveighoffer via Digitalmars-d- learn wrote: > It should really say that it's up to the GC implementation whether it's UB > or not. Well, that arguably makes it UB in general then, because it can't be relied on. By putting restrictions on the GC in gene

Re: Function template declaration mystery...

2018-03-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-03-01 12:01:19 +, Steven Schveighoffer said: Ok, here it is: https://pastebin.com/tKACi488 See lines 81-84 for how I call it. And the problem I have is that doSubscribe returns "something" I'm not sure what I can do with. But if the scope ends, my subscription seems to be deleted

Re: Garbage collected pointers?

2018-03-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/1/18 10:35 AM, John Burton wrote: On Thursday, 1 March 2018 at 12:20:08 UTC, Steven Schveighoffer wrote: On 3/1/18 7:05 AM, Gary Willoughby wrote: On Thursday, 1 March 2018 at 10:10:27 UTC, John Burton wrote: My question is how do I tell if a pointer is "garbage collected" or not? You c

Re: Garbage collected pointers?

2018-03-01 Thread John Burton via Digitalmars-d-learn
On Thursday, 1 March 2018 at 12:20:08 UTC, Steven Schveighoffer wrote: On 3/1/18 7:05 AM, Gary Willoughby wrote: On Thursday, 1 March 2018 at 10:10:27 UTC, John Burton wrote: My question is how do I tell if a pointer is "garbage collected" or not? You could try `GC.addrOf()` or `GC.query()` i

Re: Slide - what does withPartial do?

2018-03-01 Thread Seb via Digitalmars-d-learn
On Thursday, 1 March 2018 at 08:31:05 UTC, Piotr Mitana wrote: For some reason this is true: slide!(Yes.withPartial)([1, 2, 3, 4, 5], 3).array == [[1, 2, 3], [2, 3, 4], [3, 4, 5]] Shouldn't it rather return [[1], [1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5], [5]], or at least [[1, 2, 3],

Re: Garbage collected pointers?

2018-03-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/1/18 7:05 AM, Gary Willoughby wrote: On Thursday, 1 March 2018 at 10:10:27 UTC, John Burton wrote: My question is how do I tell if a pointer is "garbage collected" or not? You could try `GC.addrOf()` or `GC.query()` in core.memory. I was going to say this, but then I realized, it's not

Re: Garbage collected pointers?

2018-03-01 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 1 March 2018 at 10:10:27 UTC, John Burton wrote: My question is how do I tell if a pointer is "garbage collected" or not? You could try `GC.addrOf()` or `GC.query()` in core.memory.

Re: Function template declaration mystery...

2018-03-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/28/18 3:36 PM, Robert M. Münch wrote: Yes, that's what the docs state. And I can imagin this. Bit this sentence is a bit hard to understand: "If fun is not a string, unaryFun aliases itself away to fun." Whatever this means. It means that it simply becomes the alias you passed in. It mean

Re: Garbage collected pointers?

2018-03-01 Thread Dmitry Olshansky via Digitalmars-d-learn
On Thursday, 1 March 2018 at 10:10:27 UTC, John Burton wrote: In the language spec here :- https://dlang.org/spec/garbage.html#pointers_and_gc It refers to a distinction between pointers to garbage collected memory and pointers that are not. In particular it says that with a non garbage collec

Re: Garbage collected pointers?

2018-03-01 Thread rikki cattermole via Digitalmars-d-learn
On 01/03/2018 11:10 PM, John Burton wrote: In the language spec here :- https://dlang.org/spec/garbage.html#pointers_and_gc It refers to a distinction between pointers to garbage collected memory and pointers that are not. In particular it says that with a non garbage collected pointer you can

Garbage collected pointers?

2018-03-01 Thread John Burton via Digitalmars-d-learn
In the language spec here :- https://dlang.org/spec/garbage.html#pointers_and_gc It refers to a distinction between pointers to garbage collected memory and pointers that are not. In particular it says that with a non garbage collected pointer you can do anything that is legal in C but with a

Re: Slide - what does withPartial do?

2018-03-01 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 1 March 2018 at 08:31:05 UTC, Piotr Mitana wrote: For some reason this is true: slide!(Yes.withPartial)([1, 2, 3, 4, 5], 3).array == [[1, 2, 3], [2, 3, 4], [3, 4, 5]] Shouldn't it rather return [[1], [1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5], [5]], or at least [[1, 2, 3],

Slide - what does withPartial do?

2018-03-01 Thread Piotr Mitana via Digitalmars-d-learn
For some reason this is true: slide!(Yes.withPartial)([1, 2, 3, 4, 5], 3).array == [[1, 2, 3], [2, 3, 4], [3, 4, 5]] Shouldn't it rather return [[1], [1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5], [5]], or at least [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5], [5]]? I can see no difference o