Hacker News new | ask | show | jobs
by fwip 929 days ago
One 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))
2 comments

Existing SRFI: SRFI 49 "Indentation-sensitive syntax":

https://srfi.schemers.org/srfi-49/srfi-49.html

I 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 |.

Thanks, I knew that there must be prior art out there. :)
Whitespace significance might be the choice even more controversial than Lisp parens. For myself, I appreciate both, but those that do not, really do not.
Probably 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 :)