Re: std.range.interfaces : InputRange moveFront

2017-12-01 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 30 November 2017 at 06:36:12 UTC, Ali Çehreli wrote: import std.range; struct S { int i; bool is_a_copy = false; this(this) { is_a_copy = true; } } void main() { auto r = [S(1)]; auto a = r.front; assert(a.is_a_copy); // yes, a is a copy

Re: std.range.interfaces : InputRange moveFront

2017-12-01 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 1 December 2017 at 09:11:40 UTC, Johan Engelen wrote: I tested it and it works like you wrote, but the behavior is different for an array of integers...: Hmm, I guess I misread what Ali meant. But the documentation is wrong/very confusing for moveFront: It says "moveFront -- Remov

Re: gdc-6.3.0 on travis borked?

2017-12-01 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-01 07:20, Nick Sabalausky (Abscissa) wrote: When using gdc-6.3.0 on travis-ci, travis is reporting that it can't download the compiler: -- $ source "$(CURL_USER_AGENT="$CURL_USER_AGENT" bash install.sh gdc-6.3.0 --activate)" curl

Re: std.range.interfaces : InputRange moveFront

2017-12-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/1/17 4:29 AM, Johan Engelen wrote: On Friday, 1 December 2017 at 09:11:40 UTC, Johan Engelen wrote: I tested it and it works like you wrote, but the behavior is different for an array of integers...: Hmm, I guess I misread what Ali meant. But the documentation is wrong/very confusing

Re: associative array: unexpected results after static initialization

2017-12-01 Thread kdevel via Digitalmars-d-learn
On Friday, 1 December 2017 at 00:42:00 UTC, H. S. Teoh wrote: Here's the fix: https://github.com/dlang/druntime/pull/1980 Great. By the way: It it true, that there cannot be more than 2^32 keys in an associative array (due to the use of uint)?

Re: associative array: unexpected results after static initialization

2017-12-01 Thread kdevel via Digitalmars-d-learn
On Friday, 1 December 2017 at 00:42:00 UTC, H. S. Teoh wrote: Here's the fix: https://github.com/dlang/druntime/pull/1980 And wouldn't it be reasonable to add assert(aa.values == [ "b" ]); to the unittest?

Re: associative array: unexpected results after static initialization

2017-12-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/1/17 11:01 AM, kdevel wrote: On Friday, 1 December 2017 at 00:42:00 UTC, H. S. Teoh wrote: Here's the fix: https://github.com/dlang/druntime/pull/1980 Great. By the way: It it true, that there cannot be more than 2^32 keys in an associative array (due to the use of uint)? Yes, an

Re: associative array: unexpected results after static initialization

2017-12-01 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 01, 2017 at 04:06:50PM +, kdevel via Digitalmars-d-learn wrote: > On Friday, 1 December 2017 at 00:42:00 UTC, H. S. Teoh wrote: > > Here's the fix: > > > > https://github.com/dlang/druntime/pull/1980 > > And wouldn't it be reasonable to add > >assert(aa.values == [ "b" ])

Re: associative array: unexpected results after static initialization

2017-12-01 Thread kdevel via Digitalmars-d-learn
On Friday, 1 December 2017 at 16:23:33 UTC, H. S. Teoh wrote: On Fri, Dec 01, 2017 at 04:06:50PM +, kdevel via Digitalmars-d-learn wrote: On Friday, 1 December 2017 at 00:42:00 UTC, H. S. Teoh wrote: > Here's the fix: > > https://github.com/dlang/druntime/pull/1980 And wouldn't it be rea

Re: associative array: unexpected results after static initialization

2017-12-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/1/17 11:23 AM, H. S. Teoh wrote: On Fri, Dec 01, 2017 at 04:06:50PM +, kdevel via Digitalmars-d-learn wrote: On Friday, 1 December 2017 at 00:42:00 UTC, H. S. Teoh wrote: Here's the fix: https://github.com/dlang/druntime/pull/1980 And wouldn't it be reasonable to add a

Re: associative array: unexpected results after static initialization

2017-12-01 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 01, 2017 at 11:59:08AM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/1/17 11:23 AM, H. S. Teoh wrote: > > On Fri, Dec 01, 2017 at 04:06:50PM +, kdevel via Digitalmars-d-learn > > wrote: > > > On Friday, 1 December 2017 at 00:42:00 UTC, H. S. Teoh wrote: > > >

Re: associative array: unexpected results after static initialization

2017-12-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/1/17 12:02 PM, H. S. Teoh wrote: On Fri, Dec 01, 2017 at 11:59:08AM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: So I would say we should define that the last key/value combo takes precedence, and it would be good to ensure that's the case with a test. Sure, but that means

Re: std.range.interfaces : InputRange moveFront

2017-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 12/01/2017 01:11 AM, Johan Engelen wrote: I tested it and it works like you wrote, but the behavior is different for an array of integers...: auto a = [ 1,2,3 ]; writeln(a.front); // 1 auto b = a.moveFront(); writeln(b); // 1 writeln(a.length); // still 3 writeln(a.front); // still 1 -Joha

Re: std.range.interfaces : InputRange moveFront

2017-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 12/01/2017 07:21 AM, Steven Schveighoffer wrote: > On 12/1/17 4:29 AM, Johan Engelen wrote: >> (Also, I would expect "popFront" to return the element popped, but it >> doesn't, OK... > > pop removes the front element, but if getting the front element is > expensive (say if it's a map with a co

Re: associative array: unexpected results after static initialization

2017-12-01 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 01, 2017 at 01:14:14PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/1/17 12:02 PM, H. S. Teoh wrote: > > On Fri, Dec 01, 2017 at 11:59:08AM -0500, Steven Schveighoffer via > > Digitalmars-d-learn wrote: > > > So I would say we should define that the last key/valu

Re: std.range.interfaces : InputRange moveFront

2017-12-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/1/17 1:33 PM, Ali Çehreli wrote: On 12/01/2017 07:21 AM, Steven Schveighoffer wrote: > On 12/1/17 4:29 AM, Johan Engelen wrote: >> (Also, I would expect "popFront" to return the element popped, but it >> doesn't, OK... > > pop removes the front element, but if getting the front elemen

scope(exit) and Ctrl-C

2017-12-01 Thread Wanderer via Digitalmars-d-learn
I wonder why `scope(exit)` code is not executed when the program is terminated with Ctrl-C. For example: ``` import std.stdio; import core.thread; void main() { scope (exit) { writeln("Cleanup"); } writeln("Waiting..."); Thread.sleep(10.seconds); writeln("Done w

Re: associative array: unexpected results after static initialization

2017-12-01 Thread kdevel via Digitalmars-d-learn
On Friday, 1 December 2017 at 17:02:48 UTC, H. S. Teoh wrote: [...] There is at least 1 use case in the bugzilla issue that justifies AA literals with (possibly) duplicated keys: https://issues.dlang.org/show_bug.cgi?id=15290#c1 Code snippet: --- foreach (i; 0..10) foreach (j;

Re: scope(exit) and Ctrl-C

2017-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 12/01/2017 04:41 PM, Wanderer wrote: I wonder why `scope(exit)` code is not executed when the program is terminated with Ctrl-C. For example: ``` import std.stdio; import core.thread; void main() {     scope (exit)     {     writeln("Cleanup");     }     writeln("Waiting...");   

Re: scope(exit) and Ctrl-C

2017-12-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 2 December 2017 at 00:41:19 UTC, Wanderer wrote: I wonder why `scope(exit)` code is not executed when the program is terminated with Ctrl-C. It depends on what your operating system is. On win32, I believe it does run. On Linux (and I think Mac) you need to set a signal handler t

Re: scope(exit) and Ctrl-C

2017-12-01 Thread kdevel via Digitalmars-d-learn
On Saturday, 2 December 2017 at 00:41:19 UTC, Wanderer wrote: I wonder why `scope(exit)` code is not executed when the program is terminated with Ctrl-C. Which OS? For example: ``` import std.stdio; import core.thread; void main() { scope (exit) { writeln("Cleanup"); }

Re: scope(exit) and Ctrl-C

2017-12-01 Thread codephantom via Digitalmars-d-learn
On Saturday, 2 December 2017 at 00:41:19 UTC, Wanderer wrote: Is there any method to cleanup on Ctrl-C? // -- import std.stdio; import core.thread; extern(C) void signal(int sig, void function(int)); extern(C) void exit(int exit_val); extern(C) void handle(int

Re: scope(exit) and Ctrl-C

2017-12-01 Thread Wanderer via Digitalmars-d-learn
On Saturday, 2 December 2017 at 01:26:14 UTC, Adam D. Ruppe wrote: On Saturday, 2 December 2017 at 00:41:19 UTC, Wanderer wrote: I wonder why `scope(exit)` code is not executed when the program is terminated with Ctrl-C. It depends on what your operating system is. On win32, I believe it does

Re: scope(exit) and Ctrl-C

2017-12-01 Thread Wanderer via Digitalmars-d-learn
On Saturday, 2 December 2017 at 03:52:19 UTC, codephantom wrote: On Saturday, 2 December 2017 at 00:41:19 UTC, Wanderer wrote: Is there any method to cleanup on Ctrl-C? // -- import std.stdio; import core.thread; extern(C) void signal(int sig, void function(int

Re: scope(exit) and Ctrl-C

2017-12-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 2 December 2017 at 04:28:57 UTC, Wanderer wrote: Thanks! This works. But it seems a little bit suspicions that D's type for handler function has `nothrow` `@nogc` and `@system`. I wonder why is that? Signal handlers are ridiculously limited in what they are allowed to do. Really,

Re: scope(exit) and Ctrl-C

2017-12-01 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Dec 02, 2017 at 04:38:29AM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Saturday, 2 December 2017 at 04:28:57 UTC, Wanderer wrote: > > Thanks! This works. But it seems a little bit suspicions that D's > > type for handler function has `nothrow` `@nogc` and `@system`. I > > wond

Re: scope(exit) and Ctrl-C

2017-12-01 Thread codephantom via Digitalmars-d-learn
On Saturday, 2 December 2017 at 04:28:57 UTC, Wanderer wrote: Thanks! This works. But it seems a little bit suspicions that D's type for handler function has `nothrow` `@nogc` and `@system`. I wonder why is that? During execution of that handler, it make sense to prohibit the allocation of an

Windows Share Path

2017-12-01 Thread Vino via Digitalmars-d-learn
Hi All, Request your help, I have samll program which validates the file path, the script run perfectly when i run it manually, but if i run it via windows task scheduler i am getting "Invalid File Path or Path do not Exist", The path is a windows share, Even tried to add the net path as "

Re: Windows Share Path

2017-12-01 Thread Vino via Digitalmars-d-learn
On Saturday, 2 December 2017 at 05:08:27 UTC, Vino wrote: Hi All, Request your help, I have samll program which validates the file path, the script run perfectly when i run it manually, but if i run it via windows task scheduler i am getting "Invalid File Path or Path do not Exist", The pa