Earlier quoted context omitted.
Scala 3 decided to go with indents.
You are not telling the whole story. You can mix indentation and braces to delimit blocks. It's insane.
No Semicolons Needed
81–90 of 92 posts
Re: No Semicolons Needed
#82Earlier quoted context omitted.
Start from the perspective of the user seeing effectively: > error: expected the character ';' at this exact location The user wonders, "if the parser is smart enough to tell me this, why do I need to add it at all?" The answer to that question "it's annoying to write the code to handle this correctly" is thoroughly lazy and boring. "My parser generator requires the grammar to be LR(1)" is even lazier. Human language…
I used to hate semicolons. Then I started working in parser recovery for rustc. I now love semicolons. Removing redundancy from syntax should be a non-goal, an anti-goal even. The more redundancy there is, the higher the likelihood of making a mistake while writing, but the higher the ability for humans and machines to understand the developer's intent unambiguously. Having "flagposts" in the code lets people skim co…
Re: No Semicolons Needed
#83It might, but that's irrelevant since you never think about semicolons in Go at all.
> I like these formatting choices, but I'd prefer if the "wrong style" was still syntactically valid and a formatter would be able to fix it.
Your preference likely comes from some idealistic idea of "cleaniness" or similar, which isn't very convincing. Forcing everyone to use the same style is a huge win, to the point that it's a mistake to do anything else, as seen in the description of what Odin does. Completely wrong priorities there and refusal to learn from the past.
"Code formatting" isn't some inherent property of code that we must preserve at all costs, just a consequence of some unfortunate syntactical choices. There's no inherent reason why a language needs to allow you freedom to choose how to "format" your code. And there are in fact a lot of reasons why it shouldn't.
Re: No Semicolons Needed
#84Classic mistakes in language design that have to be fixed later. - "We don't need any attributes", like "const" or "mut". This eventually gets retrofitted, as it was to C, but by then there is too much code without attributes in use. Defaulting to the less restrictive option gives trouble for decades. - "We don't need a Boolean type". Just use integers. This tends to give trouble if the language has either implicit c…
That's because SQL null is semantically different. Most nulls are a concrete value (null pointer). SQL null is the relational null ("not known"). It's closer to NaN (but still different)
Re: No Semicolons Needed
#85Can anyone give a good reason why supporting syntax like: y = 2 * x - 3 is worth it?
Obviously, that's a really short expression. So, the question is, if you have a long expression, should you have to worry too much about either adding parentheses, or making sure that your line break occurs inside a pair of parentheses. It boils down to preference, but a language feature that supports whatever preference you have might be nice. priority = "URGENT" if hours
Re: No Semicolons Needed
#86Earlier quoted context omitted.
> I never find myself just randomly inserting characters. Hasn't it ever occured to you trying to insert a space at your mouse but your cursor wasn't there? People sometimes forget to click (or think the cursor is already there), myself included. Characters are easier to spot because they are not invisible and random letters cause compile errors. If it has never occurred to you, then good for you. However I do not se…
I don’t use the mouse when editing code, so this particular mistake does not happen to me. > I do not see what the benefit of not using closing brackets would be. Less visual noise. And the ability to use braces for other syntax.
Fair point.
> Less visual noise.
It doesn't solve this problem of your eyes guessing the correct indentation, especially when using two spaces (I hate two spaces even with braces). You could set up your IDE so it highlights the block and prints a hint at the end what block is ending, however you lose this once you open a plain text editor.
The point of using braces for this is that you can count them.
Also, if you were to print the code without braces on a paper, it would be a hard time reading, since the paper is much smaller than a 27" monitor.
> And the ability to use braces for other syntax.
There's other ways. For example, {} in Swift can be also used for ResultBuilder. And if you need the braces without knowing the type upfront, you can prefix it e.g. ${}.
Re: No Semicolons Needed
#87Perhaps having unary minus (and especially unary plus ) is just a bad idea in general; just mandate "0 - expr". To make negative constants work properly, you still have to either special case literals "256", "65536", etc. and ideally check whether they got negated or not, or introduce a special syntax just for them, like "~1" of ML for negative one, or "-1" (which you are not allowed to break with whitespace) of some…
> Also, a small prize (a "thank you!" from a stranger on the Internet i.e. me) to someone who can propose a good syntax for compound assignment with reversed subtraction: I would do away with operator-assign operators and instead introduce a general syntax for updating a variable that can be used with any expression. x = _ + 1 # increment x x = 0 - _ # negate x output = sanitizeHtml(_) index = (_ + 1) % len(arr)
Re: No Semicolons Needed
#88Earlier quoted context omitted.
Obviously, that's a really short expression. So, the question is, if you have a long expression, should you have to worry too much about either adding parentheses, or making sure that your line break occurs inside a pair of parentheses. It boils down to preference, but a language feature that supports whatever preference you have might be nice. priority = "URGENT" if hours
I don't think that syntax is comparable to breaking a simple assignment across a line break. Your syntax is perfectly clear without semicolons, right?
Re: No Semicolons Needed
#89Earlier quoted context omitted.
Exactly. I genuinely do not understand how any significant user of python can handle white space delimitation. You cannot copy or paste anything without busywork, your IDE or formatter dare not help you till you resolve the ambiguity. One day https://github.com/mathialo/bython one day!
> your IDE or formatter dare not help you Get the ones that do help you! Problem solved, enjoy your clean reading experience!
Re: No Semicolons Needed
#90Earlier quoted context omitted.
> your IDE or formatter dare not help you Get the ones that do help you! Problem solved, enjoy your clean reading experience!
The problem is that if you copy random code from the internet it cannot figure out the right indentation level - whitespace has meaning in python. What IDE can automagically handle this?
https://marketplace.visualstudio.com/items?itemName=hyesun.p...
(Sublime has the same, so does vim see comment above, so do many real IDEs)
Or do you mean something different?