by 2bitencryption · 4y ago · 0 comments
this specification is written based on the current behavior of rustc. The page even says that the specification will be updated as rustc is updated:
> If there is a mismatch between what the FLS says and how the compiler behaves, the specification will be updated.
So, rustc is not written to this specification, but rather this specification is written to match rustc.
So if I am writing my own compiler, using this specification, do I have to worry about the specification changing, if suddenly a regression is introduced to rustc, and the specification is updated to cover the regression?
mostly I don't understand. I'm sure someone could explain this and it will make sense to me.
If some old IE version did things a certain way, even the most modern browser will want to do things in a similar way to remain compatible. Therefore, the standards bodies will try to reverse-engineer the existing behaviors and then create standards based on those. That way, modern code can simply follow the spec and remain compatible.
The HTML5 parsing algorithm is an example of this. Old browsers tried to "fix" broken HTML by guessing where things like missing closing tags were supposed to go. The HTML 4 specification never described this logic, yet it was there in the wild. The new HTML 5 specification made a point of reverse-engineering the repair algorithms and actually documenting them, so now everyone can be compatible going forward, both with each other and with legacy. Just follow the spec.
It's basically an old version of the Rust Reference written out in a more bureaucratic manner.
(I see a little new material, such as the Name Resolution subsection, but even that is incomplete and I think wrong.)
Neither of these things is anywhere near close enough to being complete and correct to implement a compiler against.
An analogy from the C++ world: In late 2016, there was an evolving C++17 specification, and the latest versions of gcc and clang were starting to implement C++17 behaviors. But you could read the C++14 specification to understand "this is what everyone agreed on in 2014", and invoke your compiler with the -std=c++14 flag to get that behavior. If you already had older software written against the C++11 spec, invoke your compiler with -std=c++11.