3 ms·
Why would curly braces stop you from making the same logic error?
by jerpint 3y ago
Why would curly braces stop you from making the same logic error?
- jen20 3y agoThey don’t. They stop it being an accident though - except in languages like C where braces are optional for single line blocks which can lead to similarly poor outcomes. Whitespace sensitivity is the top of Python’s pretty exhaustive list of flaws.
- yunwal 3y agoBraces definitely do not stop accidents of this type, in my experience. All it takes is refactoring some code where you can’t feasibly count the number of open braces/parentheses (HCL tends to get like this), and misplacing a brace somewhere.
- jen20 3y ago> where you can’t feasibly count the number of open braces/parentheses (HCL tends to get like this) HCL is fine for this. Editors highlight matching braces, typically, and the parser will typically fail if they are mismatched.
- yunwal 3y ago> Editors highlight matching braces Until it doesn’t fit on the page anymore so you can’t see the highlight > parser will typically fail if they are mismatched. The concern is that your braces are technically matched, but not in the intended way, which happens a lot. Probably more than tab errors in python in my experience
- jen20 3y agoCan you give an example of HCL which is ambiguous under these conditions?