Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This article makes a strong case for every language to use ‘;’ as a statement separator.


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!


> You cannot copy or paste anything without busywork

Sounds like a tool issue. My editor (Neovim with a few plugins) can handle copying/pasting with indentation just fine.


> 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?

Do you mean "figure out that I'm pasting at level 3, so all pasted code should have +3 levels of indents" like plugins like this one do?

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?


This is nice, but it's not always the case that +3 indent is the right solution (e.g. if I'm copying already indented code it may be over indented).

It's basically a non problem in most other languages, and a IDE formatter hook will always clean up the code and organize it correctly in a way that you cannot get in Python.


Have you not used any of such IDEs/plugins? It's not X+3 indent, it's "starting at +3", so if you have lines with +10 indent (overindented) copied and paste them at +3 indent, they all get indents cut by 7 levels and end up at the same +3 level as expected.

looks cool..

Alternatively, I've several times used 'pass' as block terminator for my personal code.


Indeed it does, by showing how many different and confusing types of parsing rules are used in languages that don't have statement terminators. Needing a parser clever enough to interpret essentially a 2-d code format seems like unnecessary complexity to me, because at its core a programming language is supposed to be a formal, unambiguous notation. Not that I'm against readability; I think having an unambiguous terminating mark makes it easier for humans to read as well. If you want to make a compiler smart enough to help by reading the indentation, that's fine, but don't require it as part of the notation.

Non-statement-based (functional) languages can be excepted, but I still think those are harder to read than statement-based languages.


Lisps aren’t necessarily functional, but don’t need semicolons either.


The syntax of languages like Lisp and Forth are so fundamentally different that they don't need an explicit statement separator. You don't have to think about many other things either, or I should say you don't have to think about them in the same way. Consider how much simpler the order of operations is in those languages.


Lisp has explicit "statement" terminators (just aren't semicolons)

All the lisps I know of have only expressions (no statements).



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: