Allow while loop without parentheses for function #1870
Replies: 22 comments
-
I don't think this situation is common enough to warrant special syntax. Especially since the main motivation seem to be "the formatter doesn't behave the way I like". |
Beta Was this translation helpful? Give feedback.
-
What about using: while (SomeFunction())
continue; It is a bit more typing than just an "empty" semicolon body, but I find it to be a bit more readable for external readers.... |
Beta Was this translation helpful? Give feedback.
-
When exploring whether or not parenthesis could be removed from |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@willard720 - Unfortunately C# has a grammar that is based on the more primitive C language (and later C++ then Java). The grammar can't (easily) be changed without introducing breaking changes and eliminating parentheses is an example. I've always been disappointed when "new" languages (like Java was and C# is) emerges that actually conform to the grammar of a much older and more primitive language. I've mentioned before the PL/I language and its superb grammar that has no reserved words and does not need the silly parentheses we see all over the place in C#. Of course PL/I too is old now but the C# designers could have started with a true clean sheet of paper and designed a new grammar that avoided this antiqued syntax. Here are some of the silly things forced upon us by this grammar
|
Beta Was this translation helpful? Give feedback.
-
@Korporal
C# doesn't have any compared to other languages, like Lisp, and there's very few places where we can even remotely discuss removing them. Control keywords, being one, and casting could've been
That would actually be very confusing as they are not the same thing. Also, people coming from C/C++ know never to do
And? Alternative? How do I write
No? That's not true. You can just use a using statement. And it's probably for the best that it defaults to needing the using statement because that could cause ambiguity later. It's not even complicated to add, you just type the type, hit ctrl +. and it adds it for you...
C# does have a lot of keywords, yet 1/3 ish of them are contextual. Most of the reserved words I never would need to name something anyways, except for C# may have flaws, yet you didn't even point any of the good ones out, nor did you even give any ideas for solutions. Another thing is that C# used the "antiqued" and "primitive" language syntax for a reason. People are familiar with it. Both C and C++ are two of the greatest and most widespread languages used and have lasted decades. Seems like a good idea to follow their syntax. That's why so many big and widespread languages are classified as C-like languages. Something you're missing is that if C# had drastic changes that broke what people were familiar with, like using only Edit: Also, if you want to use a keyword, you can use public int @public = 2; // this works Other people will no what it means, so you don't need some convention like using an underscore |
Beta Was this translation helpful? Give feedback.
-
@svick In my opinion the formatter is something solidated from people's convention and familiarity. It make people could see the unintentional code. So the problem with formatter with some perfectly fine logic hint that it will not comfortable unless it be officially support Not to mention that empty body while loop would cause warning. All in all I think the problem is syntax of So I think the best option is having a syntax to intentionally loop and condition in the same block. It decrease unnecessary indented block too alternatively, There was a do SomeFunction(); // without while
do await SomeAsyncFunctionWithCallBack(() => {
await SomeTask();
return false;
}); // without while |
Beta Was this translation helpful? Give feedback.
-
@willard720 - I never said there were no reasons for the C# grammar being what it is, I simply pointed out things that I find undesirable in that grammar and the undue 'homage' it pays to C, a feeble (though popular) language with feeble grammar. As for reserved words, you misunderstand why PL/I has no reserved words. It did not do that to encourage programmers to name things after keywords (which they can) but to allow the language designers to introduce a new keyword at any time and have zero risk of breaking existing source code IF there was code out there that happened to use the new keyword for an identifier. |
Beta Was this translation helpful? Give feedback.
-
None of this part of the discussion si relevant. C# is what it is. It's in the name. It was very intentionally and explicitly chosen to continue the lineage of C-style languages. I'm sure there are communities that would be happy to discuss the relative merits of different languages (and their descendants), but it doesn't have a place in the discussion of this specific feature request. |
Beta Was this translation helpful? Give feedback.
-
@CyrusNajmabadi - The discussion began to discuss the C# grammar (be altering the syntax in some places) so I don't see why you object to us discussing the C# grammar! |
Beta Was this translation helpful? Give feedback.
-
I'm pointing out the metadiscussoin about the choices of C# that were made decades ago are not helpful. Issues are not here to re-litigate that stuff. Specifically, this part is what is unhelpful and doesn't further the conversation for this issue:
(and much of the rest htat followed that) |
Beta Was this translation helpful? Give feedback.
-
@CyrusNajmabadi - You are speculating, how do you know that these few posts do not or will not "further the conversation"? By censoring these informal discussions you run the risk of stifling innovation. If you don't find this or that post helpful or useful then so what? move on. |
Beta Was this translation helpful? Give feedback.
-
@Korporal Bringing it up repeatedly when there is nothing that can be done about it doesn't do anything to further the conversation. |
Beta Was this translation helpful? Give feedback.
-
Lamentations on the decisions made by C# two decades, which will absolutely not be changing any time soon (and will definitely not be changing due to posts in some random issue) are not helpful. They're a distraction. If you want a conversation about the decisions here and how they made be changed, they should be in a different issue. This is the issue about syntactic-changes to loop-statements. It's not the general "i'm bummed about what C# did in the past, let me bring it up and complain about it, even though that will have no impact here" issue. |
Beta Was this translation helpful? Give feedback.
-
@HaloFour @CyrusNajmabadi - I think you'll find I've submitted TWO posts in this thread about the C# grammar, one of these was a response to @willard720, so the statement "bringing it up repeatedly" is to say the least, a stretch of the truth. Stop behaving like an elitist clique for goodness sake, I've said what I said and responded to someone's reply, you guys are wasting far more time and energy on berating me than anything I posted. I'm done with this thread now, it's quite juvenile in here at times. Later. |
Beta Was this translation helpful? Give feedback.
-
@Korporal
And three other times on this repository: |
Beta Was this translation helpful? Give feedback.
-
I'm just going to throw in my opinion, while we're at it. @Korporal : I am not sure, whether your behaviour is very useful. I can see your point and I understand your arguments for some of the proposed features, but they are mostly going against the C# core design guidelines or are not backwards-compatible. I think that your argument of C# being "old-fashioned" is partially valid -- but an argumentation with PL/I is in this context IMO completely ridiculous. I haven't use PL/I before (so I cannot really judge it), but upon first glance it looks closer to some old-fashioned BASIC, PASCAL or ALGOL with way to many keywords...... I hope that you get the point, that I am trying to make here: I do not want to attack you or PL/I, but I think that in sense of "cleanness", PL/I would be a step backwards from C#. If you want to fork C# and integrate some PL/I features into it -- by all means - do it! It is a wonderful idea! Besides, being "old-fashioned" must not always be negative: Look at Haskell, it is an old language, but by far one of the best in terms of flexibility, type-safety and cleanness. Haskell has been such a great inspiration, that Microsoft even decided to create F# as new language based upon it (and on OCaml). This aside - please do consider that @CyrusNajmabadi and @HaloFour are very experienced members of the .NET community and attacking them as some "elitist clique" or "arrogant" is not at all productive. Did you consider, that they may have the best interest of C# at their hearts and have more experience of the evolution of language features than either of us? |
Beta Was this translation helpful? Give feedback.
-
@Unknown6656 - Please be logical and read what has been written not what you think has been written. You've completely misunderstood what I wrote about PL/I. I am not advocating it at all, I simply gave it as an example of a grammar that has no reserved words. You're also confusing keyword with reserved word hence you've misunderstood all that was written. Finally some here do indeed communicate as members of an elitist clique, I see it often on the internet with some technical people who feel they are special, ego is never far away sadly. |
Beta Was this translation helpful? Give feedback.
-
@Korporal
Please be polite to other community members. As for this whole "clique" thing, I don't think that it's at all inappropriate to call out that you have been repeatedly (yes, repeatedly, as in four separate times on this repository) making unconstructive statements regarding the intentional design of the language. You may disagree with that design and the lineage set forth for the C# language but this is not the place to litigate it, nor will ANYTHING come of it. C# is not going to be redesigned to be another language. You already know this. Complaining about those 20 year old decisions will not change anything. Nor will they advance any of the proposals where you've felt the need to bring this up. Your opinion is entirely valid and I share it in some aspects of the language, but it's not doing you any favors to berate the ghosts of language design past. |
Beta Was this translation helpful? Give feedback.
-
@Korporal
Then do please enlighten me -- what is in your opinion the difference between the following:
I was under the impression, that a keyword can either be:
Do please note that you can use a static keyword as a variable name in C# if you prepend it with the at-symbol ( Edit №01:By "difference" I mean: |
Beta Was this translation helpful? Give feedback.
-
@Unknown6656 - I'll leave it to the forum police to berate you for making unhelpful posts here. I wonder though if you'll get the same treatment I did...
|
Beta Was this translation helpful? Give feedback.
-
@Korporal : You really are a funny guy^^ |
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.
-
Sometimes I need to write
With the normal
while
syntax it not go well with formatterIf it would be a function I think it safe to let while body be empty and don't need to wrap parentheses around it. Because the condition in question is up to the returned value
I think it could be better if I could write it as this
Which is also made it intentionally differ from normal
while
loop that should require bodyIt should prohibit normal condition
Beta Was this translation helpful? Give feedback.
All reactions