Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: