Re:The Idea of Lisp
by vertex-four on Friday December 16, 2016 @11:16AM
(#13194236)
void in C can't be created, used, or passed around - () can.
[ Parent
| on HN ]
But void pointers can, and are often used.
Re:The Idea of Lisp
by vertex-four on Friday December 16, 2016 @02:29PM
(#13196003)
So in Rust, the equivalent of void* with references instead looks like:
enum Void{}
fn foo(v: &Void){ ... }
let bar : Void;
fn abc() -> &Void{ ...}
fn xyz() -> Void{ ... }
You can't create a Void, and you can't cast to it either - it's not a bottom type. So you can't put anything in bar. And as a result, you can't create a reference to a Void, so you can't call foo. And abc and xyz just can't be implemented in the first place.On the other hand, you can do all of these just fine:
fn foo(v: ()){ ... }
fn bar(v: &()){ ... }
...
let v = ();
bar(&v);
foo(v);
The fact that you can create and use an empty tuple as a value shows that it is not equivalent to Void.(All statements here are made within the safe subset of the language - unsafe allows access to intrinsics that would allow a Void to be made, and a reference to Void.)