9 ms·
It is really fun (sad) to see this, I've seen it so many times myself too. You show how something would be with s-expressions, compared to something, and all th
by capableweb 3y ago
It is really fun (sad) to see this, I've seen it so many times myself too. You show how something would be with s-expressions, compared to something, and all they can focus on is how many parenthesis there are. But when you sit down and count, they're the same amount as the code was when it wasn't s-expressions, just in different locations. And when you remove the parenthesis, they can kind of understand the code, kind of.
- fwip 3y agoOne option that might be suitable for a DSL, is implicit parens based on whitespace. A newline opens a new paren, and the paren closes when it reaches another line with the same indentation e.g: (defun factorial (x) (if (zerop x) 1 (* x (factorial (- x 1))))) could be rewritten as defun factorial (x) if (zerop x) 1 * x (factorial (- x 1))
- alwaysbeconsing 3y agoWhitespace significance might be the choice even more controversial than Lisp parens. For myself, I appreciate both, but those that do not, really do not.
- capableweb 3y agoProbably there are more Python users out there than combined users of all lisp-like languages, which I guess would mean people are less scared of white-space significance than s-expressions :)
- nsajko 3y agoExisting SRFI: SRFI 49 "Indentation-sensitive syntax": https://srfi.schemers.org/srfi-49/srfi-49.html https://srfi.schemers.org/srfi-49/srfi-49.html
- fwip 3y agoThanks, I knew that there must be prior art out there. :)
- Syzygies 3y agoI doubt that SRFI 49, or any other proposal I've seen online, has been battle-tested. I've written thousands of lines of Scheme using my own preprocessor, and it's my favorite code to look at. I prefer Haskell, for incredible ease of parallelism and a deeper mathematical foundation. The two features I look for in a reduced parenthesis syntax (like looking for the bone marrow in a beef stew recipe) are: 1. Some constructions begin doubly parenthesized. One needs a symbol to represent the missing object one parenthesis in. I use $. 2. One can write more expressive lines with a flavor of open paren that autocloses at the end of the line. I use |.