cc @ManishEarth: Here’s another silly idea: What if you could never store a strong reference from Rust code to a DOM object, ever? All JS object pointers would be forced with lifetimes to be stack-only. Use the reserved slot API and native JS collections for object data.
-
-
How do you create new objects? Create a rooting context first? (This is what josephine does, innit?)
1 reply 0 retweets 0 likes -
Yeah, there would be some sort of context object bound to a lifetime that you could make objects with. That would also be the lifetime for roots. No need for DOMRefCell. No need for cursor objects. No need for Traceable. No need for custom collections: just use regular JS Arrays
1 reply 0 retweets 0 likes -
Replying to @pcwalton @ManishEarth and
This is how Objective-C works, as a point of comparison. They solve the problem of regular C code not knowing anything about automatic reference counting by just banning all Obj-C objects from C containers. You can only use NSArray, etc.
2 replies 0 retweets 3 likes -
We have a bunch of cases where there's a complex type stored inside a DOM object. Especially enums.
1 reply 0 retweets 0 likes -
It’s still possible to have complex objects stored inside DOM objects, with the “Rust object wrapper” I’m proposing. Just not complex objects that themselves hold onto DOM objects. Those would have to be replaced with alternatives.
1 reply 0 retweets 1 like -
Yeah, the latter is what I'm talking about
1 reply 0 retweets 1 like -
Replying to @ManishEarth @pcwalton and
When I say complex I mean a mix of rust and js stuff.
2 replies 0 retweets 0 likes -
Well, let’s not do that then :) You can always replace that stuff with JS containers. This may have some kind of ergonomic cost, but I’m inclined to suggest that DOMRefCell and Traceable (in addition to memory unsafety!) are much worse ergonomic costs.
3 replies 0 retweets 0 likes -
Replying to @pcwalton @ManishEarth and
I wonder if a proc macro could reasonably translate rust-style structs & enums into JS objects & collections without too much ergonomic overhead. That'd be pretty neat!
2 replies 0 retweets 1 like
a.k.a. “Objective-C for the JS object model” :)
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.