Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!ut-emx!dll From: dll@ut-emx.uucp (Don Loflin) Newsgroups: comp.lang.functional Subject: Re: concrete syntax (was: "off-side rule") Keywords: whitespace Message-ID: <43322@ut-emx.uucp> Date: 28 Jan 91 19:10:44 GMT References: <4842@skye.cs.ed.ac.uk> <4167@osc.COM> Distribution: comp Organization: The University of Texas at Austin; Austin, Texas Lines: 91 In article <4167@osc.COM> jgk@osc.COM (Joe Keane) writes: [In 'C' notation]: -------- { { I think the people arguing for significant use of whitespace have good intentions, but they're a little misguided; Basically i think they're solving a problem that doesn't exist; } { In C the syntax of statements and blocks is so simple, i can state it in less than a line: a statement ends with `;', and `{' and `}' delimit blocks; I've been using C for a long time and i have a number of gripes about the language, but this is not one of them; The syntax is simple and easy to use;} { Because of the simple syntax, editing C code is easy; You can cut and paste arbitrary blocks, without having to adjust the indentation if you don't feel like it; A neat property is that you can hit M-q (fill-paragraph) in Emacs, and the code may become very hard to read but it still works fine;} { In English the rule is simple: sentences end in `.' and questions end in `?'; You could propose a scheme where periods are optional at the end of a line, and add some way to indicate that a sentence continues to the next line; But if someone did this, people would laugh at him; Why fix what isn't broken?} { Also there is the issue of readability; Some people claim that the form without a semicolon `looks better'; This is clearly a matter of taste, and it probably depends on whether you're used to reading pseudo-code or C code; I actually like the other form better; If you use a normal indenting style, it's true that the semicolon is redundant, but a little redundancy can make it easier to read;} { In FLs we have a number of schemes which make use of whitespace; But what do you gain from this; What it comes down to is that you can avoid typing a semicolon or braces in some cases; But these schemes are more complicated than those they replace; Some languages say that you can use a semicolon to separate statements, but that it's optional in certain cases depending on surrounding whitespace; By the time you have rules like this, the elegance has been lost, and you have to wonder if it wouldn't be easier to just always put the semicolon;}} -------- You really think that's more readable? Well, to each his own...:-) OK, sure, I took out all the indentation, but then, I could do the same in C, right? And the fact is, because you CAN leave it out, many DO. Take a look at any of Lee Adams'(TAB) books, the C versions -- that code is unreadable. He might as well have left it in BASIC. Yes, English uses periods, and if C used them instead of semicolons, I'd be overjoyed. And look! English uses whitespace (!) to delimit blocks (paragraphs) instead of ugly {}'s. And can you imagine if sub-paragraphs were used in English (not just Legalese) to the extent they are in C or Lisp, and we had to use {}'s or ()'s to delimit them all? Yuck. I'd go learn something easier, like Mandarin(!). Basically, explicit statement delimitation is probably a good idea, but block delimitation should use whitespace. In off-side rule languages, you do run into the problem of indenting yourself off the page. You could avoid that, but still reap the benefits of the off-side rule by using it only for block delimitation. I also suggest a modification to the rule such that the amout of white space in the first line of a block determines the amount that delimits. I.E: the C code: if (test) { statement1; while (test) { statement2; statement3; statement4; } if !(test) { statement5; else { statement6; } } becomes: if test statement1. while test statement2. statement3. statement4. if !test statement5. else statement6. ---Don Loflin, dll@emx.utexas.edu