On Thursday, 14 April 2022 at 08:55:25 UTC, Chris Katko wrote:
[...]
It appears the nested function's variable capture depends on forward declaration (the right term?). Whereas, I was under the impression most/all of D worked on a multiple pass compilation so the order of declarations shouldn't matter.

Is this a D spec, or a compiler parsing error/oversight?
[...]

This is cross-module what you're talking about, eg outside of main(). Something with most programming languages, it's not about nested function. Do it with lambda if you want, and you'll get the same result:

```d
/* auto is_Key = (ALLEGRO_KEY key) =>
(event.keyboard.keycode == key); // Not compiling! */
ALLEGRO_EVENT event;
```

You have one more option, and that is to use OOP. You can even briefly encapsulate it into a struct.

SDB@79

Reply via email to