[Proposal] C# Feature Support Omitted Keyword "void" In Function Declaration #7787
Replies: 10 comments 35 replies
-
There are no practical time loss from omitting the keyword 90+% of time spent is _reading _ code, therefore we should optimize for that instead, and personally I do not think omitting the return type makes anything more readable. Also, how often do you realistically use While there's still a fair amount of ceremony in C# (it is quite good nowadays however), this ain't it. |
Beta Was this translation helpful? Give feedback.
-
My main point is that if the keyword tells the reader that this function has no return value, then if void is not added, it doesn't mean that the function has no return value. Assuming that the reader can understand it without adding the void keyword, then why not Omit the void for simplicity?🤣🤣🤣 |
Beta Was this translation helpful? Give feedback.
-
There's usually a sweet spot. Past that point, shorter means less easy to understand. Seeing familiar patterns speeds up the understanding, similar to painted lines on a road when driving. Ambiguity is expensive. |
Beta Was this translation helpful? Give feedback.
-
This would not work well with local functions: void M() { do stuff; } // a local function M
M() { do stuff; } // same, with this proposal
M(); { do stuff; } // a call to M followed by a block |
Beta Was this translation helpful? Give feedback.
-
This is common to C, C++, Java and several other languages who's grammar is based on C. I doubt that the |
Beta Was this translation helpful? Give feedback.
-
Related to this is the possibility of removing empty parentheses on functions that take no arguments. so something like: void ResetStatus()
{
} could become ResetStatus
{
} If eliminating the |
Beta Was this translation helpful? Give feedback.
-
In what world the reasons listed in the OP make sense? seriously. I almost thought it's April Fool's Day or something.
Really? where are the numbers? because we don't use snippets. 🙉
Size is important but this is ridiculous if you think this is what we need to optimize to reduce it. I'm actually in the camp that prefers the example below over the two alternatives you gave above.
I like to waste space. 🙊
It's actually not, it makes it harder to read. Feels like reading a statement where you need to fill the empty gaps.
Yes, again, because you actually have to type that. 🙉
Yes, this is absurd. Seriously. 🙈
All except many that like their code to be crystal clear. |
Beta Was this translation helpful? Give feedback.
-
An, what/how? Does anyone really have difficulty writing the keyword In fact, this will lead to serious conflicts between determining what is a function and what is an object constructor. |
Beta Was this translation helpful? Give feedback.
-
Well I heard the same kind of arguments from COBOL aficionados, they'd say stuff like "So really, does anyone really have a problem writing |
Beta Was this translation helpful? Give feedback.
-
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.
-
FEATURE_NAME
Omitted Keyword Void
Summary
Improve development speed, and reduce extra code to do the same functionality.
Motivation
Why are we doing this?
Benefits
What use cases does it support?
What is the expected outcome?
Detailed design
If a function declaration without keyword "void", it regards as return "void", the compiler able to detect this situation such as Omitted keyword "private"(I thought).
Drawbacks
Can't compatible with low version C# , or give users a hit, to use this feature your C# version must be higher than C# 13?🤔
Beta Was this translation helpful? Give feedback.
All reactions