Hacker News new | ask | show | jobs
by marcoms 3440 days 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

1 comments

I fail to see how the usage is different? They both reference things that are 'external' eg. already compiled etc...
I 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.
No, you can also define `extern "C" fn foo() {}` with a body, which creates a function that can be called from C.