4 ms·
Being from 2013, this is speaking about Ancient Rust, but after giving this a quick re-read, it still seems up to date, with maybe minor syntax and idiom issues
by steveklabnik 11y ago
Being from 2013, this is speaking about Ancient Rust, but after giving this a quick re-read, it still seems up to date, with maybe minor syntax and idiom issues.
We _will_ be adding some sort of thing kind of like inheritance to Rust. https://github.com/rust-lang/rfcs/issues/349 https://github.com/rust-lang/rfcs/issues/349 is the RFC issue, and it outlines:
* cheap field access from internal methods;
* cheap dynamic dispatch of methods;
* cheap downcasting;
* thin pointers;
* sharing of fields and methods between definitions;
* safe, i.e., doesn't require a bunch of transmutes or other unsafe code to be usable;
* syntactically lightweight or implicit upcasting;
* calling functions through smartpointers, e.g. fn foo(JSRef<T>, ...);
* static dispatch of methods.
That being said, we don't expect this to ever be the primary method of modeling in Rust. It's just that sometimes, you do have something which is legitimately represented by inheritance or something like it.
- wrl 11y agoIs there any schedule for when that'll be worked on? It's a big thing I'm waiting on for porting some UI toolkit work to Rust.
- doomrobo 11y agoUnfortunately, almost nothing "in the pipeline" has any kind of schedule attached to it. The best you might get is a partial ordering on the priority of features.
- steveklabnik 11y agoEveryone is working on HIR/MIR at the moment, because it will enable a lot of different kinds of work to happen in parallel after it lands. The stage it's in is "Niko has a draft RFC that he hasn't published yet." Then there will be discussion, and then implementation.
- heinrich5991 11y agoWhat's HIR/MIR?
- nercury 11y agoDifferent AST representations in Rust compiler - high level and middle level.
- steveklabnik 11y agoTo build on the other answer, right now, the compiler does AST -> LLVM IR Which works, but you have to do all of the compilation passes and static checks on the AST. After this work is done, we'll have AST -> HIR -> MIR -> LLVM IR These two intermediate representations will make it easier to write frontends and backends to Rust, as well as making it easier to implement various optimization and analysis passes, and making them faster. Also, in today's world, for example, we can't stabilize syntax extensions because we'd have to stabilize the AST. But we _can_ stabilize {H,M}IR, much more easily. On the backside, we're very coupled to LLVM right now, and while that probably won't change, if someone wanted to write a backend, they could write their own codegen based off of MIR.