Any way to work around that capturing closures cannot be materialized as runtime values?
I'm trying to implement converting data from an existing, possibly nested data structure into native Mojo collections like
List
, Dict
etc. in a generic way. Here's an example for lists with one approach i've been trying:
The issue seems that list_getter
needs to close over child
in order to access it, but when I add capturing
to the function, I get the following error:
The TODO seems to indicate that this might be supported in the future, but perhaps there's a way to work around the issue today? Any pointers appreciated.6 Replies
Congrats @Sören, you just advanced to level 2!
Did you find a workaround for that? Facing the same limitation here. Thx
@Martin Dudek unfortunately not. I went with a different design approach in the end.
Congrats @Sören Brunk, you just advanced to level 3!
thx
I also found the same issue. With no global variables, the capturing closure is the only way I've found to be able to modify values in callbacks, for a event dispatcher pattern.