5 ms·
Anyone manage to build a Lisp that used semantic indentation (like Python)? You could make it optional and just have it function as a preprocessor that generate
by koenigdavidmj 16y ago
Anyone manage to build a Lisp that used semantic indentation (like Python)? You could make it optional and just have it function as a preprocessor that generates the real thing.
- eru 16y agoPerhaps Haskell can be an inspiration?
- mahmud 16y agoA cheap hack many have used is to customize their emacs high-lighting so the parens are shown only a shade away from the background color.
- leif 16y agoThere's an emacs mode for that. (http://www.emacswiki.org/emacs/UnParenMode http://www.emacswiki.org/emacs/UnParenMode) It hides the parentheses, and emacs by default will indent your lisp correctly. Just like the real thing (except you can't edit while in UnParenMode...minor issue). I do enjoy the irony in commenting with "can we get rid of the paretheses" on a post explaining why the parentheses are not important. When you truly understand lisp, you will no longer see the parentheses. They aren't real.
- burgerbrain 16y agoAre you kidding? Mandating whitespace is possibly the single worse feature of python. Lisp editing is an extremely mature topic, and rarely does a lisp programmer have to actually deal with code formatting. To turn that on it's head would be madness. A complete step backward.
- Locke1689 16y agoYou both have stupid arguments which basically boil down to "I don't like it because I prefer it the other way." This stupid flamewar has been fought countless times on countless online forums, let's not do this.
- burgerbrain 16y agoNo... my argument is: "requiring lisp programmers to pay attemtion to formatting when they haven't had to do so for years, just to make some python developers feel more at home, is stupid." Mandating whitespace complicates the situation, and for what benifit? You're the one proposing a dramatic change, show some dramatic evidence to back up your proposition.
- Locke1689 16y agoMandating whitespace complicates the situation, and for what benifit? You're the one proposing a dramatic change, show some dramatic evidence to back up your proposition. What did you not understand by "let's not do this?"
- jacobolus 16y agoPaul Graham says: > We can get rid of (or make optional) a lot of parentheses by making indentation significant. That's how programmers read code anyway: when indentation says one thing and delimiters say another, we go by the indentation. Treating indentation as significant would eliminate this common source of bugs as well as making programs shorter. http://www.paulgraham.com/popular.html http://www.paulgraham.com/popular.html
- burgerbrain 16y agoBy requiring parenthesis, indentation becomes so much simpler, the programmer doesn't even have to do it. It's done automagically.
- eru 16y agoIt's done automagically for me in Python and Haskell, too. Instead of hitting the paren keys in Emacs, I just hit tab to cycle through the possibilities. Because the Lisps have such a canonical way to indent them, in practise it feels very similar to significant whitespace with a funny input method.
- burgerbrain 16y ago"automagically", "I just hit tab" You and Understanding are not exactly on speaking terms, are you?
- eru 16y agoNormally, hitting tab just insert another \t wherever your cursor happens to be. Hitting tab in haskell-mode or python-mode just cycles through the two or three (or sometimes one) possibility for indentation for the current line. That's automagically enough for me.
- swannodette 16y agoI've fought Python's "semantic" indentation at least as much as I've fought ; : => , ( ) { } [ ] _ ' " $ < > | \ \\ \\\\ / ... et al.
- j_baker 16y agoI find this amusing because I've always found "lisp has too many parenthesis" and "python has too much significant whitespace" to be roughly equivalent in terms of relevance.
- prodigal_erik 16y agoNobody writes tools that randomly shred parentheses, but this happens all the time with whitespace. I'm halfway convinced Ruby is encroaching on Python because you can't really talk about the latter on the web without ridiculous workarounds.
- zephyrfalcon 16y agoHow so? I suppose if you paste Python code in a comment box that happens to eat whitespace, then there is a problem, yes... but for those cases there's pastebin and such. Other than that, if you're writing a blog post or article, then you can just slap the Python code in <pre> blocks, which preserves the whitespace; most "humane" text editing formats like Textile and Markdown have ways to preserve it as well.
- prodigal_erik 16y ago> comment box that happens to eat whitespace In my experience, that's easily 2/3 of the web and half of all email and IM clients. It was so bad that I was surprised when it didn't fail somehow. Pastebin is just the kind of workaround I would hate to be consigned to. Reading offline or printing becomes a huge headache because important details are constantly missing.
- jpr 16y agoOne thing that bothers me about Python's whitespace, is that it is not possible automatically indent Python code that has lost its indentation for some reason or another. You have to go back and read the original source to restore the meaning of the program even though you already have all the visible tokens it contains.
- anon_d 16y agohttp://srfi.schemers.org/srfi-49/srfi-49.html http://srfi.schemers.org/srfi-49/srfi-49.html I think it's a terrible idea, but there you go.
- stuhacking 16y agoRemoving parentheses from the syntax removes the notion that lisp programs are lists of lists. You can play around with significant whitespace all you like, but you have lost the simple representation of a list. How many hideous grammar hacks will you add to get this back?