News for hackers. Stuff that matters.
Re:Python with Braces by kazinator on Monday July 08, 2024 @06:05AM (#40904075)
> But I've seen bad-block-boundaries in Python as much as I've seen it in other languages

You have to consider ones you have not seen: the ones that are valid syntax, and thus invisible.

> (declare it as `const int a = 5` and then you have to set the value later as `a = 5` or you get an error?)?

For that, it would be more like assert (a == 5). It's not commonly done for constants. Neither the definition nor assertion are perturbed by significant whitespace, so it isn't the same.

If the constant only exists for clarity and not configuration (so the code cannot conceivably work with any other value), then the assertion would be warranted:

  assert(a == 5); // Did you read the comment about not changing a?
Re:Python with Braces by necovek on Monday July 08, 2024 @05:39PM (#40910012)
> You have to consider ones you have not seen: the ones that are valid syntax, and thus invisible.

Sure, that's a fair point, but the same holds true for braces. One of those bugs I found in non-Python code was there for a couple of years (badly placed braces).

For the other topic, you were specifically praising the duality of braces and indentation to understand block boundaries. It's hard to come up with an example where everyone does the non-obligatory thing anyways (indentation in {} languages), since obligatory thing is, well, obligatory.