You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 24, 2022. It is now read-only.
What the title says. I believe attributes would be more ergonomic and less redundant. Compare this:
entry!(main);fnmain() -> ! {// .. user code ..}exception!(HardFault, handler);fnhandler() -> ! {// .. user code ..}
to this:
#[entry]fnmain() -> ! {// .. user code ..}#[exception(HardFault)]fnhandler() -> ! {// .. user code ..}
As a bonus point we get rid of the indirection that the entry! macro requires.
entry! expands into this for type safety:
#[export_name = "main"]fn__impl_main() -> ! {// check the signature of `main`let f:fn() -> ! = main;f()}
The function call doesn't always get inlined (unless you marked main as #[inline(always)], which
looks a bit odd).
On the other hand, #[entry] expands into this:
#[export_name = "main"]pubfnmain() -> ! {// .. user code ..}
so there's no function call even when compiling without optimizations. (The type check is done
syntactically during the macro expansion)
Unresolved questions
Choose a syntax for adding state to #[exception]s.
#[proc_macro_attribute], which is required to write these macros, has already been stabilized in
nightly. #![feature(use_extern_macros)], which is required to use these macros, has not been
stabilized yet, but it's planned for the 2018 edition (1.31).
hannobraun, korken89, adamgreig and therealproftherealprof