Open koute opened 7 years ago
Does the js!
macro and the set of bindings to web APIs belong in the same crate?
I'm not very familiar with the architecture of stdweb, but it seems to me that generating JS from Rust and calling JS APIs from WASM/asm.js-compiled Rust are orthogonal. I'd imagine that applications would be written predominantly with one or the other!
@LPGhatguy Well, they're not completely orthogonal, although, yes, the js!
could be in its own crate on which the API bindings would depend on.
If you look at our src
directory you can clearly see this split - basic JS interop is in the src/webcore
, while API bindings are in src/webapi
. It would be possible to split these two directories into two separate crates, however I don't want to do that yet as it would only increase friction without any real benefits. (The compiler is pretty good at eliminating dead code, so even if you only use the js!
macro you're not paying for the rest of the stdweb
you're not using.)
It looks like procedural macros are planned for stabilization in Rust 2018. Has there been any progress on this issue?
@Kwarrtz Nope. But I do plan to do this once procedural macros are actually stabilized.
The
js!
macro is truly a thing of terror, however we don't have much choice if we want to work on stable.That said, it would we worthwhile to convert it to a nightly-only procedural macro to prepare for the future where procedural macros will be stabilized.
This will also help with the compile times, which are negatively impacted by the way the current
js!
macro is implemented.js!
procedural macro.nightly
optional feature toCargo.toml
and use the proceduraljs!
only when that feature is switched on.