5 ms·
For me what's quite unnerving about `extern crate` is that the `extern` keyword has another function, that is to declare foreign functions [0]. `extern crate` o
by marcoms 10y ago
For me what's quite unnerving about `extern crate` is that the `extern` keyword has another function, that is to declare foreign functions [0]. `extern crate` on the other hand, is not an extension of `extern` but serves a completely different purpose.
0: https://doc.rust-lang.org/book/ffi.html https://doc.rust-lang.org/book/ffi.html
- deleted 10y ago[deleted]
- neikos 10y agoI fail to see how the usage is different? They both reference things that are 'external' eg. already compiled etc...
- marcoms 10y agoI mean if anything the syntax should me more specialised as you go into sub-keywords, which makes sense in this industry (e.g. ISO 8601). The problem is that `extern` seems to have been taken from C++ and extern crate is almost tacked on (or that's the impression I get). Comparing with other languages, Rust looks to be the only instance where two keywords are required to simply require a module/library, which sticks out to me.
- Manishearth 10y agoNo, you can also define `extern "C" fn foo() {}` with a body, which creates a function that can be called from C.