2 ms·
In SWT, even though Java is garbage-collected, resources must be explicitly disposed[1]. Often they are bound to the lifetime of a parent object and disposed wh
by ptx 7y ago
In SWT, even though Java is garbage-collected, resources must be explicitly disposed[1]. Often they are bound to the lifetime of a parent object and disposed when that parent is disposed.
This seems to work OK in SWT, so what's the problem in GTK/Rust? Are there some particular categories of objects that don't fit into that hierarchical model and need to be handled with a GC?
(Those objects would presumably be regular Java objects in an SWT app and handled by Java's GC.)
[1] https://www.eclipse.org/articles/swt-design-2/swt-design-2.html https://www.eclipse.org/articles/swt-design-2/swt-design-2.h...
- pjmlp 7y agoThe problem is called borrow checker, and that while the Rust team already has done lots of improvements with NLL, the use of widget data in callbacks remains a pain point. "Appendix: What the proposal won’t fix" http://smallcultfollowing.com/babysteps/blog/2017/07/11/non-lexical-lifetimes-draft-rfc-and-prototype-available/ http://smallcultfollowing.com/babysteps/blog/2017/07/11/non-... So one could say, it is a case of holding it wrong, and a Rust UI toolkit needs to be written from scratch. Which might be ok, but it does require some support for market adoption. Having said this, Gtk-rs now has some help in the form of relm, exactly to overcome this issue. https://github.com/antoyo/relm https://github.com/antoyo/relm