Re: Patterns to avoid GC with capturing closures?

2018-08-25 Thread vit via Digitalmars-d-learn
On Friday, 24 August 2018 at 15:18:13 UTC, Peter Alexander wrote: Consider this code, which is used as an example only: auto scaleAll(int[] xs, int m) { return xs.map!(x => m * x); } As m is captured, the delegate for map will rightly allocate the closure in the GC heap. In C++, you would

Re: Solving the impossible?

2018-08-25 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 26 August 2018 at 02:26:58 UTC, Everlast wrote: The problem is, suppose one wants to specify A void print(T, int... A)(T t, A a) while tricks can be used, why doesn't D support such an obvious syntax? We can specify an arbitrary type but can't restrict it in an obvious way, in fact

Solving the impossible?

2018-08-25 Thread Everlast via Digitalmars-d-learn
void print() { } void print(T, A...)(T t, A a) { import std.stdio; writeln(t); print(a); } The problem is, suppose one wants to specify A void print(T, int... A)(T t, A a) while tricks can be used, why doesn't D support such an obvious syntax? We can specify an arbitrary type but

Re: "The D Way" to run a sequence of executables?

2018-08-25 Thread JN via Digitalmars-d-learn
On Friday, 24 August 2018 at 17:36:25 UTC, Matthew OConnor wrote: I'd like to run a sequence of executables with something like std.process.execute, but I would like the sequence to error out if one of the executables returns a non-zero return code. What is the recommended way to do this? A wra

Re: "The D Way" to run a sequence of executables?

2018-08-25 Thread JN via Digitalmars-d-learn
On Saturday, 25 August 2018 at 22:00:47 UTC, JN wrote: It's kind of a dirty and not very portable solution, but if you run by executeShell, you could so something like executeShell("cmd1 && cmd2 && cmd3") and let the shell do the sequence for you. Oops, didn't notice it was suggested already.

Re: How do you actually run the "Start a minimal webserver" example on the home page

2018-08-25 Thread Radu via Digitalmars-d-learn
On Saturday, 25 August 2018 at 20:37:04 UTC, Everlast wrote: On Saturday, 25 August 2018 at 20:28:55 UTC, Chris M. wrote: On Saturday, 25 August 2018 at 20:17:35 UTC, AN wrote: I downloaded the script and made it executable. I also have dub on `/usr/bin/dub` . The example just stalls with no o

Re: How do you actually run the "Start a minimal webserver" example on the home page

2018-08-25 Thread Everlast via Digitalmars-d-learn
On Saturday, 25 August 2018 at 20:28:55 UTC, Chris M. wrote: On Saturday, 25 August 2018 at 20:17:35 UTC, AN wrote: I downloaded the script and made it executable. I also have dub on `/usr/bin/dub` . The example just stalls with no output. After fidgeting around for 5 minutes I realized it was

Re: How do you actually run the "Start a minimal webserver" example on the home page

2018-08-25 Thread Chris M. via Digitalmars-d-learn
On Saturday, 25 August 2018 at 20:17:35 UTC, AN wrote: I downloaded the script and made it executable. I also have dub on `/usr/bin/dub` . The example just stalls with no output. After fidgeting around for 5 minutes I realized it was downloading silently in the background. (I think for homepage

How do you actually run the "Start a minimal webserver" example on the home page

2018-08-25 Thread AN via Digitalmars-d-learn
I downloaded the script and made it executable. I also have dub on `/usr/bin/dub` . The example just stalls with no output. After fidgeting around for 5 minutes I realized it was downloading silently in the background. (I think for homepage examples, they should be running in verbose mode as th

Re: Null-Coalescing Operator and Extensions

2018-08-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-08-25 15:33, SG wrote: Hi, 1) I program in C# and I'm wondering if there is something like ?? (Null-Coalescing Operator) in D? (I remember some proposals in the past). Not in the language but it can be implemented as a library function by overloading "opDispatch". See [1] for an exam

Re: Clock.currTime differs from SysTime

2018-08-25 Thread Ivo via Digitalmars-d-learn
Thanks a lot. The issue was indeed the time zone.

Re: Circular reference error gone after inspecting members

2018-08-25 Thread Yuxuan Shui via Digitalmars-d-learn
Issue filed: https://issues.dlang.org/show_bug.cgi?id=19190

Re: Clock.currTime differs from SysTime

2018-08-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, August 25, 2018 6:53:24 AM MDT Ivo via Digitalmars-d-learn wrote: > I am using Clock.currTime.stdTime to get a unique timestamp in my > program. > Now I need to produce something similar in a different > programming language; so I'm trying to understand how > Clock.currTime works. > >

Re: Circular reference error gone after inspecting members

2018-08-25 Thread Yuxuan Shui via Digitalmars-d-learn
On Saturday, 25 August 2018 at 14:13:18 UTC, rikki cattermole wrote: On 26/08/2018 2:10 AM, Yuxuan Shui wrote: The offending code base is a little big and hard to reduce. I'll try if code is required, but here is the gist of the problem: This snippet of code in my project:     ...     alia

Re: Circular reference error gone after inspecting members

2018-08-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/08/2018 2:10 AM, Yuxuan Shui wrote: The offending code base is a little big and hard to reduce. I'll try if code is required, but here is the gist of the problem: This snippet of code in my project:     ...     alias tmp = genCode!T;     enum str = tmp.str; // This line here     ...

Circular reference error gone after inspecting members

2018-08-25 Thread Yuxuan Shui via Digitalmars-d-learn
The offending code base is a little big and hard to reduce. I'll try if code is required, but here is the gist of the problem: This snippet of code in my project: ... alias tmp = genCode!T; enum str = tmp.str; // This line here ... Generate a circular reference error. However,

Re: Null-Coalescing Operator and Extensions

2018-08-25 Thread SG via Digitalmars-d-learn
On Saturday, 25 August 2018 at 13:42:30 UTC, JN wrote: 2) Yes, through UFCS (Uniform Function Call Syntax). It doesn't require any special syntax, for example: Very simple indeed. Thanks.

Re: Null-Coalescing Operator and Extensions

2018-08-25 Thread JN via Digitalmars-d-learn
On Saturday, 25 August 2018 at 13:33:58 UTC, SG wrote: Hi, 1) I program in C# and I'm wondering if there is something like ?? (Null-Coalescing Operator) in D? (I remember some proposals in the past). 2) Is possible to create Extensions like in C#? For example: public int StrToInt (this st

Null-Coalescing Operator and Extensions

2018-08-25 Thread SG via Digitalmars-d-learn
Hi, 1) I program in C# and I'm wondering if there is something like ?? (Null-Coalescing Operator) in D? (I remember some proposals in the past). 2) Is possible to create Extensions like in C#? For example: public int StrToInt (this string s){ return int.Parse(s); } var i = "123456".Str

Clock.currTime differs from SysTime

2018-08-25 Thread Ivo via Digitalmars-d-learn
I am using Clock.currTime.stdTime to get a unique timestamp in my program. Now I need to produce something similar in a different programming language; so I'm trying to understand how Clock.currTime works. According the the documentation Clock.currTime.stdTime should return the number of hnse