It's awesome to have a lot of syntactic sugar for the compiler for things like
overloading operators, automatic borrows (@mut in a lib), etc. What's
unfortunate is that each of these features requires a new `lang_item` to be
defined by the compiler *and* any crate which is compiled.

To alleviate this problem, I think it'd be a really slick idea to make all
`lang_item` attributes optional. The phases of compilation would only change
such that when one is required, then an error is emitted saying that a
`lang_item` needs to be implemented. It would have the span of the ast which
caused the `lang_item` to be required, so it would be pretty easy to infer what
would need to happen.

This would make `zero.rs` even smaller than it is today, and it would also allow
our `lang_item` count to grow quickly without causing unnecessary burden on
users who don't use `libstd`. Any new `lang_item` wouldn't be available to
someone immediately, but it's not required for their project to implement it
if they don't want.

This is kind of in the vain of getting as close to a "runtime-less" hello-world
as possible. Currently you can combine `zero.rs` with `libc`, but `zero.rs` is a
few hundred lines of mostly empty traits and functions which are never used or
just abort anyway. Good chunks of it are probably still required, though.

Do others think that this is a good idea? I still think that it's a
good idea to at least attempt to keep the lang_item count reasonable,
but at some point it's also nice to have overloaded syntax for various
operators.
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to