3 ms·
I don't see what you want to explain. Could you be a bit more specific ? In the use-case you describe, what don't you think could be done with a language with a
by littlestymaar 9y ago
I don't see what you want to explain. Could you be a bit more specific ? In the use-case you describe, what don't you think could be done with a language with affine type system ?
- pjmlp 9y agoBecause the editor needs to update the type relations according to your mouse clicks and property editor changes, given the semantics of affine types I only see it being possible with some kind of heuristics. Very basic example, 1 - Drag component into the form, variable could be declared as owned 2 - Edit a relationship between the component and another one on the property editor, either generate code with borrows or update the owned declaration into a Rc one, Arc instead, or Rc with RefCell, Arc with RefCell,....? The GUI editor needs heuristics to create declarations with the right set of affine types, or to update existing ones when the developer clicks around changing the document tree and relations among them. Oh and the current state of the borrow checker in Rust doesn't handle closures for self in callbacks, which makes it a royal pain to write GUI event handlers.
- littlestymaar 9y ago> The GUI editor needs heuristics to create declarations How about using move by default, if the compiler complains about moving the data, falls back to Rc<RefCell<T>>, and if the compiler complains about `Send` use Arc<Mutex<T>>. Or you could even use the later for everything in your UI designer, this way you get a memory management scheme which is like Swift's. (In first approximation at least, since Swift has CoW for some kind of things, but you could definitely copy the exact Swift behavior in Rust if you wanted). As I said earlier, the affine type system is opt-out in Rust, so you can do whatever you need without it(including your GUI stuff) and still be able to benefit from it when writing your business logic, and being more productive thanks to it.