Jump to page: 1 2 3
Thread overview
May 09
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 of static if and runtime foreach. This allows declarations to be generated using an imperative loop.

If you are interested in static foreach making it into the language, please play with the implementation and tell me how to break it. It would also be nice to get some code reviews (the implementation is the result of two days of exhausting trial-and-error figuring out how the DMD frontend works).

May 09
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

May 09
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.
May 09
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
May 09
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_staticforeach.d

EPIC! Thank you so much for doing this!

> adds 'enum' and 'alias' on foreach loop variables to force one of the two.
> (Also works with existing foreach over AliasSeq.)

I was wondering, would it be possible to move this to a separate pull request and get it merged before the rest? It would be useful on its own and probably would stand a chance of getting merged much faster... before every detail of static-foreach is agreed upon?

May 09
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.

May 09
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 to me.

I guess having written your own D frontend from scratch must have helped!

https://github.com/tgehr/d-compiler
May 09
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/tgehr/dmd/blob/static-foreach/src/test_staticforeach.d
>
> EPIC! Thank you so much for doing this!
> ...

Well, there was a hackaton, and I needed to do _something_. :)
I thought this will have the highest impact.

>> adds 'enum' and 'alias' on foreach loop variables to force one of the
>> two.
>> (Also works with existing foreach over AliasSeq.)
>
> I was wondering, would it be possible to move this to a separate pull
> request and get it merged before the rest? It would be useful on its own
> and probably would stand a chance of getting merged much faster...
> before every detail of static-foreach is agreed upon?
>

Yes, I'll do that.
May 09
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/oenjmm$lds$1@digitalmars.com

Also, the DIP has existed for three years, it's just not very polished:
https://wiki.dlang.org/DIP57
May 09
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
>

Moved: https://github.com/tgehr/dmd/blob/static-foreach/test_staticforeach.d
« First   ‹ Prev
1 2 3