3 ms·
I think the C/C++ convention with curly braces is ok, and doesn't make the parser much more complicated. Any closing brace has an obvious matching opening brace
by amelius 6y ago
I think the C/C++ convention with curly braces is ok, and doesn't make the parser much more complicated. Any closing brace has an obvious matching opening brace. And the meaning of any opening brace can be easily deduced from context, I suppose.
- dklend122 6y agoPersonally, I much prefer end to braces. They have the benefit also of being usable for indexing and array expressions
- improbable22 6y agoOther things are OK too. I quite like that if/elseif/else/end only needs one closing, no other openings. I don't know whether using {} for both types & blocks would be hard to parse, maybe it's possible. I have heard & can believe that parsing <> as a 4th ascii bracket is pretty tricky.
- amelius 6y agoI have heard & can believe that parsing <> as a 4th ascii bracket is pretty tricky. That's probably because < can appear without >, e.g. in a<b.
- ddragon 6y agoWhile I like do...end for symmetry, most of the time the end will have the same indentation as whatever opened it, and everything in between will be one indentation ahead (especially if you're using an automatic formatter), so I can follow easily without reading the content. And whatever opened it will also explicitly tell the context (if it's a method definition, if/else, for...). In the end my code ends up like python but with an extra end, which, while adding a possibly unnecessary line of code it at least makes it trivial to copy and paste something into the repl (or other part of the code) without worrying about indentation.