Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is Void? Maybe rename to Unknown? #11158

Closed
jeffbdavenport opened this issue Sep 2, 2021 · 2 comments
Closed

What is Void? Maybe rename to Unknown? #11158

jeffbdavenport opened this issue Sep 2, 2021 · 2 comments

Comments

@jeffbdavenport
Copy link

Let me preface this with that I believe I know what Void is. It just doesn't make any sense.

As far as I can tell, Crystal's use of Void, is essentially to integrate with C where the type is not really known, or doesn't need to be known. Typically seen when using Pointers to some unknown or undefined object.

But the problem here is that the name itself "Void" does not agree with this context. It lets the user believe that what they are working with is actually empty, untouched, or perhaps even Null.

Void in C is to indicate that a function actually does not return any value at all. Not that it returns some unknown value, or does something unknown. It means that it is literally nothing, not even empty, not unknown, and not Null.

The type Void in Crystal needs to be changed to something that makes more sense as to what it contains. Perhaps Unknown?

Maybe I am just misunderstand Void altogether and I am just a Crystal noob. I have been programming for the last 9 years, and 3 of them with Crystal, and I still cannot wrap my head around "Void" in Crystal as it doesn't make any sense.

@straight-shoota
Copy link
Member

Crystal itself essentially has no actual Void type. In Crystal, it's just Nil. Void is only used for C bindings and Void pointers. For C bindings the name is obviously correct, because it's C terminology.
Outside of C bindings, Void should not really be useful and we should restrict its usage even further (see #10657), perhaps even removing it entirely (except for bindings) with a UntypedPointer type as replacement for Pointer(Void) (#10749).

@jeffbdavenport
Copy link
Author

I knew that Void was not a Crystal type, wasn’t trying to say that it was. But I did not realize that void pointer was a thing in C. I guess that’s where my complaint belongs, with the C language.

I think UntypedPointer much better explains what a void pointer is, than “void pointer”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants