@szakharin Yes. The trampolines are also problematic that they require executable stack (at least in the implementations I’ve seen), which is often not allowed. We implemented the nested functions (closures) by creating a module and sharing the needed variables via pointers. I think this approach is cleaner and should be faster, but we have not done any thorough benchmarking yet.
certik
26
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Question about CONTAINS | 30 | 2327 | February 26, 2023 | |
| How does the compiler handle functions and subroutines? | 22 | 1785 | February 15, 2023 | |
| Implementation of a parametrized objective function without using module variables or internal subroutines | 71 | 1395 | July 25, 2025 | |
| Generic interface with subroutine and function | 19 | 2341 | December 18, 2023 | |
| Pure wrappers for impure procedures | 13 | 1602 | April 15, 2022 |