Wcp Ess Expressions

Costin's conjecture: wikis badly need structured data.

WikiChangeProposal is initially targeted to geeks who think that XmlSucks and XmlIsaPoorCopyOfEssExpressions and so on, so forth, but hardly do anything about it so the market is left to Microsoft, Sun and Apache XML pars. On the other hand I found myself hating the situation where somebody would force me to type XML in a edit box. I could have used one of the many high quality Scheme implementation for Java, but ended up writing my own S-Expression parser for a particular syntax, partly because of the challenge and hubris involved, and partly because I thought I needed a few extra-features and I had prototyped something on another of my pet projects.

I think it was a good design decision to use s-expressions because I now find myself adding any kind of feature in no time.

So here's the basic syntax for S-Expression:

 #<< TERMINATOR
 all kinds of
 things go here until the terminating word is recognized after a new line
 TERMINATOR


What I've been contemplating lately is to introduce a syntax for shortcutting the clsing of paranthesis. Because closing paranthesis in Scheme/Lisp is a drag, and it looks ugly. The syntax I am thinking of is not general (cannot shortcut all paranthesis), but should cover a majority of the situations.

For example:
 (define (split-in-two lst)
   (if (null? lst)
      '()
       (letrec ((iter (lambda (p1 p2)
                      (cond ((null? p2) (cons '() p1))
                            ((null? (cdr p2)) (cons '() p1))
                            (#t (let ((result (iter (cdr p1) (cddr p2))))
                                  (cons (cons (car p1) (car result)) (cdr result)
                     ))))))
               )
        (iter lst lst)
   )))
where I avoided the typical Scheme conventions in order to show the paranthesis that are just too many too close and kind of a sore to the eye. So in the new notation I would have:
 (define (split-in-two lst)
   (if (null? lst)
      '()
      (letrec ((iter (lambda (p1 p2)
                      (cond ((null? p2) (cons '() p1))
                            ((null? (cdr p2)) (cons '() p1))
                            (#t (let ((result (iter (cdr p1) (cddr p2))))
                                  (cons (cons (car p1) (car result)) (cdr result)
                     )/iter  )
        (iter lst lst)
   )/define
Where )/sname closes all the lists up to the list that started with the first element being a the symbol designated by sname. I find this closing of many paranthesis to be a very common occurrence in Lisp/Scheme and it kind of bothered me, especially if you want to edit S-Expression in the text box of a browser. Anybody cares to comment, or is anybody having a better idea?

Behold the mighty SuperBracket?: ] ! It has been cleaning up the tails of Lisp EssExpressions for many a year.

Yes, and nice clean EssExpressions still look better and I'm guessing make drag and drop or cut and paste of entire expressions much easier. The super bracket must die.

"Super brackets" (more commonly called "super parenthesis") are quite ancient by now, and way back when, it meant "close all currently open parens"). They used to be popular.

But for a long while now, bracket has instead been used, as someone said above, "for diversification". That's not the whole of the story, though. It's very important that close bracket only matches open bracket, not an open paren; that helps to group things in an error-free way.

The above code using the bracket convention is simply (with mild and imperfect change of indent to accentuate a bracket):

 [define (split-in-two lst)
   (if (null? lst)
      '()
      (letrec (
                     [iter (lambda (p1 p2)
                      (cond ((null? p2) (cons '() p1))
                            ((null? (cdr p2)) (cons '() p1))
                            (#t (let ((result (iter (cdr p1) (cddr p2))))
                                  (cons (cons (car p1) (car result)) (cdr result)
                     ]  )
        (iter lst lst)
 ]
Paren levels are guaranteed to match (sum to zero) within each bracket expression.

Anyway, Costin's notation might combine well with that standard bracket convention. I wouldn't want the bracket convention to be outright replaced, though. -- DougMerritt
[1] WcpEssExpressions closely follows RonaldRivest's proposal http://theory.lcs.mit.edu/~rivest/sexp.html , but with more primitive types.


CategoryWikiChangeProposal

EditText of this page (last edited August 4, 2006) or FindPage with title or text search