| ▲ | bobbydigitales 11 hours ago |
| What kinds of things do you think might not translate well? |
|
| ▲ | tombert 11 hours ago | parent | next [-] |
| Not the OP, but I'm thinking about like closures? Say you wanted to make a Node.js framework with callbacks that react to an event. The callback might be a closure that captured some of its surrounding variables. At that point, any of the captured variables are not trivially stack-allocated. You might be able to do something similar to what Rust does with moving though. |
| |
| ▲ | jandrewrogers 10 hours ago | parent | next [-] | | Typically you would construct this state in statically allocated memory. A lot of systems work this way. Dynamic heap allocation isn’t the only alternative to stack allocation. | |
| ▲ | skew-aberration 11 hours ago | parent | prev | next [-] | | You could predefine your event handlers within your context, then call 'enter framework' and pass your event handlers as arguments. this is continuation passing style | | |
| ▲ | cmrx64 11 hours ago | parent [-] | | it is, but more specifically it’s an eliminator for a coinductive step. |
| |
| ▲ | com2kid 10 hours ago | parent | prev [-] | | Nah we did something similar on Microsoft Band. I wrote about how - https://meanderingthoughts.hashnode.dev/cooperative-multitas... The tldr is you had to preallocate a struct with anything you wanted captured ahead of time. |
|
|
| ▲ | thayne 9 hours ago | parent | prev [-] |
| Say you wanted a map of some key to growable arrays (or maps), where the number of keys isn't known until runtime. It I understand correctly, you can't really do that because the number of growable stacks nees to be known at compile time. |