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).

Reply via email to