Void is surprisingly useful.
Void is surprisingly useful.
Posted Sep 9, 2026 13:42 UTC (Wed) by iabervon (subscriber, #722)In reply to: Void is surprisingly useful. by ralfj
Parent article: Stabilizing Rust's never type
I think it's not really a type at all; it's a keyword used in places in type declarations where an optional type parameter isn't used. While "int *" is "pointer to int", "void *" isn't "pointer to void", it's just "pointer". "int (*)(int)" is "function that takes int and returns int", but "void (*)(int)" is "function that takes int and calling it is a statement rather than an expression", and "int (*)(void)" is "function that returns int". Subsequent language design research showed that optional type parameters are a bad idea, and you can make your parameterized types uniform by including some types that the compiler optimizes (like having "function that returns a value you must discard" instead), but that's not how C was designed, so void ends up with all the weirdness that you get if you try to have a value that embodies the effects of not using something optional.
The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:
Note: you can avoid this step in the future by logging into your LWN account.
