Shorthand syntax for closing braces #1662
Replies: 13 comments
-
No, it's not. It's a hideous mess. |
Beta Was this translation helpful? Give feedback.
-
Can't imagine this would have a different reception than #1441. |
Beta Was this translation helpful? Give feedback.
-
That was poorly recieved because the |
Beta Was this translation helpful? Give feedback.
-
@lazyloader This proposal is probably going to be poorly received because of the distracting brace indentation style (don't take this the wrong way, but both examples were hard for me to read), and after that, because of your assertion that the lines of closing braces we write today are "complete code bloat." |
Beta Was this translation helpful? Give feedback.
-
I rather think #1441 received a poor reception because skipping closing delimiters is a really bad idea. They're no more code bloat than good spelling or correct grammar in English. Shorter code isn't automatically better. |
Beta Was this translation helpful? Give feedback.
-
You should not endeavour to create scope mountains. Reorganize your code instead of looking for workarounds. C# is not a language of significant whitespace, so this is not very idiomatic. |
Beta Was this translation helpful? Give feedback.
-
Think about it. There's only one possible place where such a syntax is even remotely applicable, and that is at the last part of the last method of the last type declared within a file, and only if the very last statement itself happens to be nested multiple levels deep. It's useless anywhere else as it would close the definition of the method, type and namespace where it would be used, preventing you from declaring anything afterwards without even more boilerplate than would've otherwise been necessary. |
Beta Was this translation helpful? Give feedback.
-
@lazyloader Why are you proposing such language changes? It seems to me that you are rather unhappy with the C# syntax in its current form -- and that's OK. I would therefore like to ask you: Why aren't you using an other language? |
Beta Was this translation helpful? Give feedback.
-
@Unknown6656 It's not my call. Unity was mostly designed for C# (and other langauges but mostly everyone uses C#) and that's what the rest of the team is using so it would be weird to try and use some hacked F# when only one of us would be using it. Thing is though I do love C#. I mean, how many other mainstream languages can use expression bodied methods, have properties, or do stuff like turn this public MyClass(Arg1 arg1, Arg2, arg2, Arg3 arg3)
{
Arg1 = arg1;
Arg2 = arg2;
Arg3 = arg3;
} into this public MyClass(Arg1 arg1, Arg2, arg2, Arg3 arg3) => (Arg1, Arg2, Arg3) = (arg1, arg2, arg3); And from my understanding, records will be making that even easier? It's cool working in such an active language that's constantly improving and adding new features. I'm exicited for the future of C# and where it's going and it would be cool to request a feature that makes it in. C# has had a lot of features that tried moving fluff from the code (some of my favorite features) which is why I purpose those, to try and shorten the code (or improve readability). |
Beta Was this translation helpful? Give feedback.
-
@lazyloader : I completely understand your position concerning the "pressure" of your dev team to work with C# instead of a functional language to keep internal consistency. I can completely understand your thirst to suggest a feature that will make it into the actual release of a C#-version, however I have the feeling that you are going in a kind of a wrong direction. It is important to suggest features, that are not only existent to "be a part of the C# LDT", e.g.: I quickly learned, that one must broaden their minds and also think about "missing features" as follows: Furthermore, it is important to develop features which serve a wide number of C# devs and are not the future source of bad coding practises themselves. ExampleI will take your proposal #1651 as example:
Just simply asking these questions before submitting a proposal can help take an objective view of the proposal's usage cases and need. Now, I am not thinking or saying, that you didn't think about your proposals before submitting them here - What I am simply saying is, that it is important to take a broader and more critical view on the entire matter. TL;DRFollow the 'checklist' before proposing a new feature:
Indecently, do please forgive my ignorance, but I thought that Unity could be used with F# - can't it? ... Aaaaand here comes a very important final note:I know that we (the LDT and the majority of the community) may seem like utter assholes for "downvoting" or "rejecting" some of your ideas - but the following is important:
|
Beta Was this translation helpful? Give feedback.
-
@lazyloader There are a number of issues with the proposal, but the main problem I see with this proposal is it only works at the end of the file. It turns out this is also the one place in a source file where a long sequence of curly braces is easily ignorable (because it already had no code following it). A few other alternatives are available as well, such as switching to the use of One True Brace instead of the Allman style more commonly seen in C# code. 💭 What if instead of this proposal, the IDE had a command to close any remaining braces? At worst that would be fairly easy to implement in an extension (if it doesn't already exist). |
Beta Was this translation helpful? Give feedback.
-
@sharwell That's a great idea. I could see myself using that to insert closing parens, too. |
Beta Was this translation helpful? Give feedback.
-
Since the OP is using the Whitesmiths style of braces, which every C# developer on the planet save for @lazyloader finds unreadable, the solution to this seems obvious to me: namespace N
{
class C
{
public void Foo()
{
if (someCondition)
{
}
else
{
}}}}} It's still completely unreadable, but is no worse than before. And it now avoids "lots of lines that are just braces" as @lazyloader wanted. Problem solved. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Why not instead of doing
we could just simply do something like
other ideas could be
}...
,} all
,end
,braces
, etc.The result is it is much more readible and easier to understand without having to waste so many lines of code of just tabs, on complete code-bloat.
Beta Was this translation helpful? Give feedback.
All reactions