Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clone function in lib_oo cannot deep-copy a KOSDelegate that uses closures #2

Open
stevemeacham opened this issue Oct 17, 2020 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@stevemeacham
Copy link
Owner

Problem:
Closure-referenced variables cannot be copied. Any closure-reference will forever refer to the same variable in the same memory location. This prevents deep copying of any KOSDelegate, or structure that contains a KOSDelegate.

If the closure-referenced variable is immutable (i.e. never changed after the closure is established), this is not a problem in practice. However, if the variable that is deep copied along with the KOSDelegate, the KOSDelegate will still refer to the original variable, not the copy.

As a workaround, only use closures to refer to immutable variables if the KOSDelegate could possibly be cloned().

The solution seems to be impossible in Kerboscript alone. Perhaps by modifying the .ksm byte-code? Perhaps by adding deep-copy semantics to Kerboscript itself that makes this work? I think that Rust can re-bind closures, for example.

@stevemeacham stevemeacham added enhancement New feature or request help wanted Extra attention is needed labels Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant