Re: Simple casting?

2019-11-25 Thread Alex via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 05:17:54 UTC, Taylor R Hillegeist wrote: On Tuesday, 26 November 2019 at 05:05:48 UTC, Taylor R Hillegeist wrote: I'm attempting to do a segment group. details: alias ProbePoint[3]=triple; triple[] irqSortedSet = UniqueTriples.keys

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

2019-11-25 Thread aliak via Digitalmars-d-learn
On Sunday, 24 November 2019 at 17:04:49 UTC, Steven Schveighoffer wrote: On 11/24/19 10:44 AM, aliak wrote: [...] Hm.. are you sure that ctrl-c isn't also sending the signal to your child process? I thought it did. -Steve Yesh, you're right. That extra kill is unnecessary and was

Re: why local variables cannot be ref?

2019-11-25 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Nov 25, 2019 at 08:07:50AM +, Fanda Vacek via Digitalmars-d-learn wrote: [...] > But anyway, pointers are not allowed in @safe code, so this is not > always solution. [...] This is incorrect. Pointers *are* allowed in @safe code. Pointer *arithmetic* is not allowed. --T

Re: why local variables cannot be ref?

2019-11-25 Thread Dukc via Digitalmars-d-learn
On Monday, 25 November 2019 at 03:07:08 UTC, Fanda Vacek wrote: 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` ref int b() { return a; } b = 2;

Re: why local variables cannot be ref?

2019-11-25 Thread Fanda Vacek via Digitalmars-d-learn
On Monday, 25 November 2019 at 05:51:31 UTC, Rumbu wrote: 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() {

Re: why local variables cannot be ref?

2019-11-25 Thread rumbu via Digitalmars-d-learn
On Monday, 25 November 2019 at 08:20:59 UTC, rumbu wrote: On Monday, 25 November 2019 at 08:07:50 UTC, Fanda Vacek wrote: Thanks for answer, I'm coming from C++. But anyway, pointers are not allowed in @safe code, so this is not always solution. Workaround exits even for @safe code, so my

Re: why local variables cannot be ref?

2019-11-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 25, 2019 1:32:53 AM MST H. S. Teoh via Digitalmars-d- learn wrote: > On Mon, Nov 25, 2019 at 08:07:50AM +, Fanda Vacek via > Digitalmars-d-learn wrote: [...] > > > But anyway, pointers are not allowed in @safe code, so this is not > > always solution. > > [...] > > This is

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

2019-11-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 25, 2019 1:22:17 AM MST Andrej Mitrovic via Digitalmars- d-learn wrote: > From: > https://github.com/dlang/phobos/blob/10b9174ddcadac52f6a1ea532deab3310d3a8 > c03/std/concurrency.d#L1913-L1916: > > - > /// > final @property bool isClosed() @safe @nogc pure > { >

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

2019-11-25 Thread Andrej Mitrovic via Digitalmars-d-learn
From: https://github.com/dlang/phobos/blob/10b9174ddcadac52f6a1ea532deab3310d3a8c03/std/concurrency.d#L1913-L1916: - /// final @property bool isClosed() @safe @nogc pure { synchronized (m_lock) { return m_closed; } } - I don't understand the purpose of this lock.

Re: why local variables cannot be ref?

2019-11-25 Thread rumbu via Digitalmars-d-learn
On Monday, 25 November 2019 at 08:07:50 UTC, Fanda Vacek wrote: Thanks for answer, I'm coming from C++. But anyway, pointers are not allowed in @safe code, so this is not always solution. Workaround exits even for @safe code, so my question remains the same. What is a rationale for such a

Re: Leak-detection of references to scoped class instances

2019-11-25 Thread Jacob Carlborg via Digitalmars-d-learn
On Sunday, 24 November 2019 at 21:49:19 UTC, Per Nordlöw wrote: I guess we need a builtin language qualifier for scoped classes for that to work, right? We have that: scope a = new Object; — /Jacob Carlborg

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

2019-11-25 Thread aliak via Digitalmars-d-learn
On Sunday, 24 November 2019 at 16:05:14 UTC, mipri wrote: On Sunday, 24 November 2019 at 15:44:00 UTC, aliak wrote: [...] This might be useful: --- #! /usr/bin/env rdmd import std; import core.stdc.signal; [...] waitpid, of course! Thanks agin :)

Re: how to implement a function in a different D source file

2019-11-25 Thread mipri via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 03:06:52 UTC, Omar wrote: Hey, I'm very interested in this programming language, I already prefer it to C++ and if only i had adopted it years ago, but that's beside the point. I read a bunch of tuts today and the only thing I'm really stuck on at the moment

Re: how to implement a function in a different D source file

2019-11-25 Thread mipri via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 03:06:52 UTC, Omar wrote: the page here https://dlang.org/spec/function.html suggests you can implement a function in a different file ... mentioned the endeavour of no-bodied-functions as a way of presenting a black-box type of interface. oh, that's what you

Simple casting?

2019-11-25 Thread Taylor R Hillegeist via Digitalmars-d-learn
I'm attempting to do a segment group. details: alias ProbePoint[3]=triple; triple[] irqSortedSet = UniqueTriples.keys .sort!("a[1].irqid < b[1].irqid",SwapStrategy.stable) .array; 83:triple[][] irqSortedSets =

Re: how to implement a function in a different D source file

2019-11-25 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 03:55:24 UTC, mipri wrote: On Tuesday, 26 November 2019 at 03:06:52 UTC, Omar wrote: the page here https://dlang.org/spec/function.html suggests you can implement a function in a different file ... mentioned the endeavour of no-bodied-functions as a way of

Re: Simple casting?

2019-11-25 Thread Taylor R Hillegeist via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 05:05:48 UTC, Taylor R Hillegeist wrote: I'm attempting to do a segment group. details: alias ProbePoint[3]=triple; triple[] irqSortedSet = UniqueTriples.keys .sort!("a[1].irqid < b[1].irqid",SwapStrategy.stable)

Re: how to implement a function in a different D source file

2019-11-25 Thread Elronnd via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 03:06:52 UTC, Omar wrote: the page here https://dlang.org/spec/function.html suggests you can implement a function in a different file, and a different tutorial somewhere else mentioned the endeavour of no-bodied-functions as a way of presenting a black-box type

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

2019-11-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/25/19 3:22 AM, 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 m_closed;     } }

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

2019-11-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/25/19 3:55 AM, aliak wrote: On Sunday, 24 November 2019 at 17:04:49 UTC, Steven Schveighoffer wrote: On 11/24/19 10:44 AM, aliak wrote: [...] Hm.. are you sure that ctrl-c isn't also sending the signal to your child process? I thought it did. Yesh, you're right. That extra kill is

Re: why local variables cannot be ref?

2019-11-25 Thread Timon Gehr via Digitalmars-d-learn
On 25.11.19 10:00, Dukc wrote: On Monday, 25 November 2019 at 03:07:08 UTC, Fanda Vacek wrote: 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` ref int b() {

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

2019-11-25 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 25 November 2019 at 09:24:43 UTC, Jonathan M Davis wrote: On Monday, November 25, 2019 1:22:17 AM MST Andrej Mitrovic via Digitalmars- d-learn wrote: From: https://github.com/dlang/phobos/blob/10b9174ddcadac52f6a1ea532deab3310d3a8 c03/std/concurrency.d#L1913-L1916: - /// final

Re: Leak-detection of references to scoped class instances

2019-11-25 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 25 November 2019 at 08:22:02 UTC, Jacob Carlborg wrote: On Sunday, 24 November 2019 at 21:49:19 UTC, Per Nordlöw wrote: I guess we need a builtin language qualifier for scoped classes for that to work, right? We have that: scope a = new Object; — /Jacob Carlborg Ahh, nice.

Re: Leak-detection of references to scoped class instances

2019-11-25 Thread mipri via Digitalmars-d-learn
On Monday, 25 November 2019 at 12:08:54 UTC, Per Nordlöw wrote: On Monday, 25 November 2019 at 08:22:02 UTC, Jacob Carlborg wrote: On Sunday, 24 November 2019 at 21:49:19 UTC, Per Nordlöw wrote: I guess we need a builtin language qualifier for scoped classes for that to work, right? We have

Re: Generating DDOX documentation

2019-11-25 Thread Huynh Nguyen via Digitalmars-d-learn
On Friday, 20 October 2017 at 10:47:57 UTC, Andrew Edwards wrote: Given a documented source file (eg. process.d), I can generate the DDOC version of the documentation with the -D switch of DMD as such: $ dmd -Dfprocess.html process.d What do I modify on that line to get the DDOX version

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: What is the point of a synchronized lock on a single return statement?

2019-11-25 Thread Robert Schadek via Digitalmars-d-learn
But be aware, even though the bool is returned from a synchronized block, its actual value has no meaning at all. All the meaning you get out of that bool is that the MessageBox was closed when you called that function. If there is a function in MessageBox that can reopen the instance, you

Anything like HPPTOD out there?

2019-11-25 Thread ParticlePeter via Digitalmars-d-learn
I would like to auto convert c++ header to d module. Is there some project aiming for this? I know of VisualD c++ to d conversion wizzard [1] and LLVM tooling based CPP2D [2], both of them aiming for whole cpp conversion. But I a searching for something lightweight like HTOD extended to C++.

How to create DDoc for string mixin generated functions?

2019-11-25 Thread ParticlePeter via Digitalmars-d-learn
I am producing a bunch of functions/methods through string mixins. I also generated DDoc comments for those functions, in the hope that they would produce proper documentation, but they don't. So how can this be accomplished?

Re: Anything like HPPTOD out there?

2019-11-25 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 25 November 2019 at 16:35:21 UTC, ParticlePeter wrote: I would like to auto convert c++ header to d module. Is there some project aiming for this? I know of VisualD c++ to d conversion wizzard [1] and LLVM tooling based CPP2D [2], both of them aiming for whole cpp conversion. But

Re: Casting from int to long

2019-11-25 Thread Yui Hosaka via Digitalmars-d-learn
On Monday, 18 November 2019 at 15:16:11 UTC, Yui Hosaka wrote: I have encountered some kind of "32-bit / 64-bit issues" several times (https://issues.dlang.org/show_bug.cgi?id=20162, https://issues.dlang.org/show_bug.cgi?id=20128). Not sure it is related, but DMD32 with -O has the following

Re: why local variables cannot be ref?

2019-11-25 Thread Fanda Vacek via Digitalmars-d-learn
On Monday, 25 November 2019 at 08:32:53 UTC, H. S. Teoh wrote: On Mon, Nov 25, 2019 at 08:07:50AM +, Fanda Vacek via Digitalmars-d-learn wrote: [...] But anyway, pointers are not allowed in @safe code, so this is not always solution. [...] This is incorrect. Pointers *are* allowed in

Re: why local variables cannot be ref?

2019-11-25 Thread Fanda Vacek via Digitalmars-d-learn
On Monday, 25 November 2019 at 09:00:49 UTC, Dukc wrote: On Monday, 25 November 2019 at 03:07:08 UTC, Fanda Vacek wrote: 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

Re: Leak-detection of references to scoped class instances

2019-11-25 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 25 November 2019 at 13:09:44 UTC, mipri wrote: gdc assembly. ldc eliminates the object entirely. DIP-1000 kicks comes to the rescue here aswell: class C { @safe pure nothrow @nogc: this(int x) { this.x = x; } int x; } C leakClass() @safe pure nothrow {

Re: Leak-detection of references to scoped class instances

2019-11-25 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 25 November 2019 at 13:09:44 UTC, mipri wrote: gdc assembly. ldc eliminates the object entirely. Thanks.

Re: why local variables cannot be ref?

2019-11-25 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Nov 25, 2019 at 08:39:08PM +, Fanda Vacek via Digitalmars-d-learn wrote: > On Monday, 25 November 2019 at 08:32:53 UTC, H. S. Teoh wrote: > > On Mon, Nov 25, 2019 at 08:07:50AM +, Fanda Vacek via > > Digitalmars-d-learn wrote: [...] > > > But anyway, pointers are not allowed in

how to implement a function in a different D source file

2019-11-25 Thread Omar via Digitalmars-d-learn
Hey, I'm very interested in this programming language, I already prefer it to C++ and if only i had adopted it years ago, but that's beside the point. I read a bunch of tuts today and the only thing I'm really stuck on at the moment is how to actually implement a function in a different