Idea: void datatype #2767
Replies: 4 comments
-
Beta Was this translation helpful? Give feedback.
-
I like this idea; it would allow generic types to take void as a type parameter, reducing duplication of code (e.g. |
Beta Was this translation helpful? Give feedback.
-
538 isn't what I'm talking about. |
Beta Was this translation helpful? Give feedback.
-
I would have uses for a feature in this direction. Type conversions from void would be handy. Would be less enthused by an approach equating |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Right now, there is a gulf between methods that return something, and methods that do not return something. This seems very unlike the rest of C#'s unifiedness, in the same way that it eschewed Java's gulf between objects and primitives. I think it would be a good idea to define
void
as a type whose only valid value isvoid
, whether this means defining a new zero-sized struct or just usingvoid
as an alias toSystem.ValueTuple
with no parameters when used as a type. This would fulfill the same use asUnit
in Kotlin,()
in Rust, orVoid
in Java, and allow void methods to be passed where aFunc
or similar is expected.Beta Was this translation helpful? Give feedback.
All reactions