Open lachbaer opened 7 years ago
Just did a search of my code: I have zero occurrences of do while
in that code. So it's a π from me as I'd probably not use do until
either.
@DavidArno do ... while
is just in that example. It could be while (cond) ...
also. Do you have while (!...) ...
in your code?
Good point. Yes, I found half a dozen or so uses of while
. In all cases the expression was a positive one (no occurrences of while (!expression)
, so until
wouldn't work for me. So I've changed my vote to π
Sorry, I'm clearly the wrong audience for this feature π
That's what this survey is about π
In 60 years nobody has felt the need to add it to C/C++. Not even D added it. I just don't think it's necessary.
I'd be much more for exploring allowing the !
operator to appear outside of the parenthesis, which could apply to both if
and while
:
do {
PullNewItems(itemlist, source);
Process(itemlist);
} while !(list.IsFull || source.IsEmpty);
I'd be much more for exploring allowing the ! operator to appear outside of the parenthesis,
It would be interesting to have a poll for this, though I doubt that the team is susceptible to that neither. Should that poll be concurrent to this one or better delayed until many more have voted here?
I have my doubts that the team are considering these polls much in general. The participating audience here is just too small. It's not like UserVoice where we're amassing thousands of votes.
I'll put up a separate proposal/discussion for the !
idea, though.
I have my doubts that the team are considering these polls much in general.
The idea of the polls is to get a rough overview about how the community here is thinking in general without provoking a confusingly long discussion where the overview could be lost quickly.
This is much like the if !(condition)
discussion. Simply omitting the parenthesis would fix the issue.
while !condition
or while condition
or do { ... } while condition;
or do { ... } while !condition;
, and of course the parenthesis would remain perfectly legal so that if (condition)
would legal, and in many project required I'd assume. π
@HaloFour
In 60 years nobody has felt the need to add it to C/C++.
I don't think that's a valid argument. In 60 years, nobody has felt the need to add LINQ or expression-bodied members or pattern matching to C/C++ either. Especially C is a very different language than C#, with very different goals.
@svick
Sweeping language features are a little different from minor grammar tweaks (well, expression-bodied members definitely fall into that latter category). All it does is move the negation from the expression and into the keyword, adding another way of doing something you could already do. Is it more readable? Perhaps in some scenarios. It's exceptionally minor, but in my opinion so is the benefit. And it may open the door to applying elsewhere in the language. We've already had requests for unless
to negate if
.
Even looking at the discussion of removing the parenthesis to make negation a little "clearer" has only opened a can of worms of horrific code rife with ambiguities.
I don't like the idea of adding new keyword. I prefer if!
and while!
All keyword should be operator
Meanwhile I'd prefer having until
only as a conditional for the do
statement.
Starting a 'sentence' with until
looks somehow strange to me. And there is no other language I know that starts a statement with until
.
But as a final conditional keyword in a do-loop I still think that it can be useful:
do { ... } until (condition)
I think whether until
will be useful can be decided objectively. Some source code scrapper can look for use of while
and do...while
and then check whether the condition for while is negative or not (starts with !
or not). If the negative conditions are of a higher percentage, adding until
and do...until
loops will be helpful for programmers. One can argue that why introduce a new keyword when we can just have while not
? I think, until
is more intuitive than while not
.
Because it always comes up from time to time π
The
until
keyword is available in many other programming languages and is made much use of. In C-derived languages however it does not exist, because it can be expressed bywhile (!(...))
. Nevertheless, there seem to be quite some people who would like to have it additionally, not only in C#.This poll is not about discussing
until
! It shall only be a rough survey on how community members currently think.Sample:
vs.
Poll
while (!...)
while (!...)
while
constructwhile(!...)
as reading 'until' if they like