Arc Forumnew | comments | leaders | submitlogin
1 point by czoon 5909 days ago | link | parent

1.

  (def paren-adder ((o delimiter '$))
     (rfn parens (expr)
        (if atom.expr expr
            (let (hd . tl) expr
               (if (is hd delimiter)
                  (list parens.tl)
                  (cons parens.hd parens.tl))))))
2.

  (def paren-adder ((o delimiter '$))
     : rfn parens (expr)
        : if atom.expr expr
            : let (hd . tl) expr
               : if (is hd delimiter)
                  (list parens.tl)
                  : cons parens.hd parens.tl )
compare them.

maybe its just me, but i dont like that ")))))))))" MORP or endless sea of right parens.

its not a big problem but "parenthes Less lisp" is better for me.

if i remember correctly, somebody mentioned here that Interlisp has solution with square brackets .

but i think this way is more readable.

probably, you are right about functional code. thanks for your reply.



1 point by eds 5907 days ago | link

I don't think right parentheses are a problem for the following reasons:

* I don't type right parens. If you use Emacs and haven't tried Paredit (http://mumble.net/~campbell/emacs/paredit.el), I would highly suggest it.

* I don't read right parens, at least not in the multiline case. Instead, I read the indentation and the contents of the line, so the parens really don't get in the way at all.

I do think the : operator is an interesting idea for the single line case, when you might have something like

  (foo a (bar b (baz c))) => (foo a : bar b : baz c)
in the middle of a line.

-----

1 point by czoon 5904 days ago | link

and once get used to that , its addictive.

-----

1 point by rincewind 5903 days ago | link

Pythonic:

  (def paren-adder ((o delimiter '$)) :
     rfn parens (expr) :
        if atom.expr expr :
            let (hd . tl) expr :
               if (is hd delimiter)
                  (list parens.tl)
                  (cons parens.hd parens.tl))

-----