Anyway, that's a summary of how I saw the conversation unfold; correct anything you see as wrong in this summary. It got a little heated and I don't want to misrepresent anyone's opinion.
I think you just missed one of the points why I wanted to introduce a cycle. The structure is semantically cyclic. We just represent one of the edges with "these two integers are the same". Having a real pointer makes it easier to understand.
This also got to the question of how to control what can mutate a data structure. In clang (which is written is C++ and compiles C++), it is really important that random parts of the FE don't mutate the AST since changes to it can invalidate things like C++'s crazy name lookup rules. To have that and at the same time allow for cycles, the AST is a friend of the parts that construct it. Which is ugly, but does allow them to be sure about which parts of the code can mutate the AST.
Sorry for bringing even harder questions, but this also got me thinking about one of the nice features of C/C++: the ability to represent not only cycles, but arbitrary memory layout. Is there a plan to implement something similar in rust?
For example, if I implement a JS interpreter or JIT in C/C++, I can give its data structures any layout that is appropriate for the JS implementation. If, for example, a garbage collector is used for the JS objects they don't need a reference count, but I can still get a pointer to it from the C++ code.
I am sure this is not safe in general, but it would be sad to have to go back to C/C++ for any unsafe operation.
An example that is probably closer to the issues we will have after bootstrap: can rust's garbage collector be written in rust?
-Graydon [1] Fold should really be an obj eventually; we just didn't have obj-extension working in rustboot at the time
Cheers, Rafael _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
