Hi everyone,

Currently, the keyword "extern" is highly overloaded. "extern" has the following meanings:

1. "extern fn" in a type means "a function that closes over nothing" (at least at one point; if this has already changed then disregard.)

2. "extern fn" in a declaration means "a function callable as a callback from C to Rust". In this case the type is actually *u8, not "extern fn". The latter means something completely different -- namely, (1) above -- a fact that causes numerous problems, including the inability to write generic callbacks.

3. "extern mod foo { ... }" means "a module of C functions in a native library called foo".

4. "extern mod foo;" means "link to the Rust crate named foo".

These multiple meanings of the keyword "extern" seem highly confusing. To fix this, I propose the following changes:

(a) Fix #1 above by making the type of a Rust function that closes over nothing simply "&static/fn(...) -> ...".

(b) Fix #2 above by making the type of such callbacks "extern fn(...) -> ...".

(c) Fix #4 by changing the syntax to link against a crate to something else. I don't really have any opinions as to what the exact syntax should be; the proposed "link" keyword seems like a fine choice, or maybe something like "use lib".

Thoughts?

Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to