Re: Static foreach pull request

2017-05-11 Thread Steven Schveighoffer via Digitalmars-d
On 5/10/17 3:45 PM, Stefan Koch wrote: On Wednesday, 10 May 2017 at 18:41:30 UTC, Timon Gehr wrote: On 10.05.2017 16:21, Stefan Koch wrote: On Wednesday, 10 May 2017 at 14:13:09 UTC, Timon Gehr wrote: On 10.05.2017 15:18, Stefan Koch wrote: if you try assert([] is null), it should fail. It

Re: Static foreach pull request

2017-05-10 Thread Stefan Koch via Digitalmars-d
On Wednesday, 10 May 2017 at 18:41:30 UTC, Timon Gehr wrote: On 10.05.2017 16:21, Stefan Koch wrote: On Wednesday, 10 May 2017 at 14:13:09 UTC, Timon Gehr wrote: On 10.05.2017 15:18, Stefan Koch wrote: if you try assert([] is null), it should fail. It doesn't. I have tried to make that poin

Re: Static foreach pull request

2017-05-10 Thread Timon Gehr via Digitalmars-d
On 10.05.2017 16:21, Stefan Koch wrote: On Wednesday, 10 May 2017 at 14:13:09 UTC, Timon Gehr wrote: On 10.05.2017 15:18, Stefan Koch wrote: if you try assert([] is null), it should fail. It doesn't. I have tried to make that point before, unsuccessfully. Empty arrays may or may not be null,

Re: Static foreach pull request

2017-05-10 Thread Stefan Koch via Digitalmars-d
On Wednesday, 10 May 2017 at 14:13:09 UTC, Timon Gehr wrote: On 10.05.2017 15:18, Stefan Koch wrote: if you try assert([] is null), it should fail. It doesn't. I have tried to make that point before, unsuccessfully. Empty arrays may or may not be null, but the empty array literal is always

Re: Static foreach pull request

2017-05-10 Thread Timon Gehr via Digitalmars-d
On 10.05.2017 15:18, Stefan Koch wrote: if you try assert([] is null), it should fail. It doesn't. I have tried to make that point before, unsuccessfully. Empty arrays may or may not be null, but the empty array literal is always null.

Re: Static foreach pull request

2017-05-10 Thread Stefan Koch via Digitalmars-d
On Wednesday, 10 May 2017 at 13:11:46 UTC, Atila Neves wrote: On Wednesday, 10 May 2017 at 11:12:06 UTC, Stefan Koch wrote: null : () { Slice* s; s = null; return s; } [] : () { Slice* s; s = alloca(sizeof(*s)); s.base = null; s.length = 0; return s; } Therefore null.length => (cast(Slice*

Re: Static foreach pull request

2017-05-10 Thread Atila Neves via Digitalmars-d
On Wednesday, 10 May 2017 at 11:12:06 UTC, Stefan Koch wrote: On Wednesday, 10 May 2017 at 09:42:53 UTC, Timon Gehr wrote: [...] So here is the difference between null and []: null : () { Slice* s; s = null; return s; } [] : () { Slice* s; s = alloca(sizeof(*s)); s.base = null; s.length =

Re: Static foreach pull request

2017-05-10 Thread Stefan Koch via Digitalmars-d
On Wednesday, 10 May 2017 at 09:42:53 UTC, Timon Gehr wrote: On 09.05.2017 23:56, Timon Gehr wrote: core.exception.AssertError@ddmd/blockexit.d(90): Assertion failure ... Thanks! (It's a known issue though: https://github.com/tgehr/dmd/blob/static-foreach/test_staticforeach

Re: Static foreach pull request

2017-05-10 Thread Timon Gehr via Digitalmars-d
On 09.05.2017 23:56, Timon Gehr wrote: core.exception.AssertError@ddmd/blockexit.d(90): Assertion failure ... Thanks! (It's a known issue though: https://github.com/tgehr/dmd/blob/static-foreach/test_staticforeach.d#L330.) Actually, yours is a different case with the same o

Re: Static foreach pull request

2017-05-09 Thread Timon Gehr via Digitalmars-d
On 09.05.2017 23:56, Timon Gehr wrote: core.exception.AssertError@ddmd/blockexit.d(90): Assertion failure ... Thanks! (It's a known issue though: https://github.com/tgehr/dmd/blob/static-foreach/test_staticforeach.d#L330.) I guess the problem is that I do not propagate the e

Re: Static foreach pull request

2017-05-09 Thread Andrei Alexandrescu via Digitalmars-d
On 5/10/17 1:00 AM, Andrei Alexandrescu wrote: On 5/10/17 12:56 AM, Timon Gehr wrote: Thanks! (It's a known issue though: https://github.com/tgehr/dmd/blob/static-foreach/test_staticforeach.d#L330.) I guess the problem is that I do not propagate the error condition properly, but I'm not sur

Re: Static foreach pull request

2017-05-09 Thread Andrei Alexandrescu via Digitalmars-d
On 5/10/17 12:56 AM, Timon Gehr wrote: Thanks! (It's a known issue though: https://github.com/tgehr/dmd/blob/static-foreach/test_staticforeach.d#L330.) I guess the problem is that I do not propagate the error condition properly, but I'm not sure how to do it. (In my frontend, error handling

Re: Static foreach pull request

2017-05-09 Thread Timon Gehr via Digitalmars-d
On 09.05.2017 23:39, Guillaume Boucher wrote: On Tuesday, 9 May 2017 at 03:06:37 UTC, Timon Gehr wrote: If you are interested in static foreach making it into the language, please play with the implementation and tell me how to break it. Code: void main() { void f() { idonotexist(); }

Re: Static foreach pull request

2017-05-09 Thread Guillaume Boucher via Digitalmars-d
On Tuesday, 9 May 2017 at 03:06:37 UTC, Timon Gehr wrote: If you are interested in static foreach making it into the language, please play with the implementation and tell me how to break it. Code: void main() { void f() { idonotexist(); } static foreach(j;0..0) {

Re: Static foreach pull request

2017-05-09 Thread Andrei Alexandrescu via Digitalmars-d
On 5/9/17 3:46 PM, Timon Gehr wrote: On 09.05.2017 08:17, rikki cattermole wrote: On 09/05/2017 7:10 AM, Jack Stouffer wrote: On Tuesday, 9 May 2017 at 03:06:37 UTC, Timon Gehr wrote: ... I'm going to save you some time and tell you that Andrei and Walter are going to require a DIP for this.

Re: Static foreach pull request

2017-05-09 Thread Timon Gehr via Digitalmars-d
On 09.05.2017 05:42, Timon Gehr wrote: On 09.05.2017 05:06, Timon Gehr wrote: ... Some examples: https://github.com/tgehr/dmd/blob/71ab1280c88f9f0922fabf89ab3e7e1164b70e8b/src/test_staticforeach.d Better link: https://github.com/tgehr/dmd/blob/static-foreach/src/test_staticforeach.d Mov

Re: Static foreach pull request

2017-05-09 Thread Timon Gehr via Digitalmars-d
On 09.05.2017 08:17, rikki cattermole wrote: On 09/05/2017 7:10 AM, Jack Stouffer wrote: On Tuesday, 9 May 2017 at 03:06:37 UTC, Timon Gehr wrote: ... I'm going to save you some time and tell you that Andrei and Walter are going to require a DIP for this. http://forum.dlang.org/thread/oenjm

Re: Static foreach pull request

2017-05-09 Thread Timon Gehr via Digitalmars-d
On 09.05.2017 09:26, Daniel N wrote: On Tuesday, 9 May 2017 at 03:42:48 UTC, Timon Gehr wrote: On 09.05.2017 05:06, Timon Gehr wrote: ... Some examples: https://github.com/tgehr/dmd/blob/71ab1280c88f9f0922fabf89ab3e7e1164b70e8b/src/test_staticforeach.d Better link: https://github.com/tgeh

Re: Static foreach pull request

2017-05-09 Thread Vladimir Panteleev via Digitalmars-d
On Tuesday, 9 May 2017 at 09:17:06 UTC, Corey wrote: On Tuesday, 9 May 2017 at 03:06:37 UTC, Timon Gehr wrote: (the implementation is the result of two days of exhausting trial-and-error figuring out how the DMD frontend works). First time dealing with the frontend? Heck, two days sounds fast

Re: Static foreach pull request

2017-05-09 Thread Corey via Digitalmars-d
On Tuesday, 9 May 2017 at 03:06:37 UTC, Timon Gehr wrote: (the implementation is the result of two days of exhausting trial-and-error figuring out how the DMD frontend works). First time dealing with the frontend? Heck, two days sounds fast to me.

Re: Static foreach pull request

2017-05-09 Thread Daniel N via Digitalmars-d
On Tuesday, 9 May 2017 at 03:42:48 UTC, Timon Gehr wrote: On 09.05.2017 05:06, Timon Gehr wrote: ... Some examples: https://github.com/tgehr/dmd/blob/71ab1280c88f9f0922fabf89ab3e7e1164b70e8b/src/test_staticforeach.d Better link: https://github.com/tgehr/dmd/blob/static-foreach/src/test_sta

Re: Static foreach pull request

2017-05-08 Thread rikki cattermole via Digitalmars-d
On 09/05/2017 7:10 AM, Jack Stouffer wrote: On Tuesday, 9 May 2017 at 03:06:37 UTC, Timon Gehr wrote: ... I'm going to save you some time and tell you that Andrei and Walter are going to require a DIP for this. http://forum.dlang.org/thread/oenjmm$lds$1...@digitalmars.com

Re: Static foreach pull request

2017-05-08 Thread Jack Stouffer via Digitalmars-d
On Tuesday, 9 May 2017 at 03:06:37 UTC, Timon Gehr wrote: ... I'm going to save you some time and tell you that Andrei and Walter are going to require a DIP for this.

Re: Static foreach pull request

2017-05-08 Thread Timon Gehr via Digitalmars-d
On 09.05.2017 05:06, Timon Gehr wrote: ... Some examples: https://github.com/tgehr/dmd/blob/71ab1280c88f9f0922fabf89ab3e7e1164b70e8b/src/test_staticforeach.d Better link: https://github.com/tgehr/dmd/blob/static-foreach/src/test_staticforeach.d

Static foreach pull request

2017-05-08 Thread Timon Gehr via Digitalmars-d
Code: https://github.com/dlang/dmd/pull/6760 Some examples: https://github.com/tgehr/dmd/blob/71ab1280c88f9f0922fabf89ab3e7e1164b70e8b/src/test_staticforeach.d This is a complete proof-of-concept implementation of "static foreach". The semantics of the construct are given by merging the ones