[plt-scheme] Scheme contradictions

From: hendrik at topoi.pooq.com (hendrik at topoi.pooq.com)
Date: Thu May 4 10:13:17 EDT 2006

On Thu, May 04, 2006 at 02:27:57PM +0100, Vladimir Zlatanov wrote:
> The funniest bit of all is that scheme and/or lisp have one of the
> cleanest syntax conventions of them all. And probably that is the 
> biggest downside. In most of the mentioned languages like Python, Ruby,
> Perl, C, php, plug your own, the weirdness in syntax is helping the
> immediate visual recognition of what is going on. In scheme the visual
> overview of a piece of code gets you only to a certain point, then you
> need to start counting parenthesis, or at least the instinct tells you
> so.
> 
> I'm a scheme novice, but I have some experience in programming, so
> these are my own impressions. I do like the clean syntax, but it really
> gets to me, when I need do go down dirty and count, simply because I
> made a typo. The [] addition helps with visual qeues. But is it enough?
> 
> Maybe it can be a good thing to add python/ruby/haskell like layout
> syntax. I know there were experiments flying around. Recently Peter
> Schombert wrote an anlysis in his blog about it:
>    http://pschombe.wordpress.com/2006/04/16/lisp-without-parentheses
> I think it is a good idea, at least for people with experience in other
> languages, to come to the lisp family. It is kind of syntactic sugar,
> which can increase the readability of a program.
> 
> I wouldn't mind having a go at this, the algorithm is nothing special,
> just keep track of the context in a stack, there are one or two gotchas
> more that in Peter's blog post, but still it shouldn't be hard. I just
> wouldn't like doing a work already done - as far as I understand the
> mzscheme reader already does indent tracking. It is used for error
> reports and in the DrScheme indentation code. 
> 
> How complicated, and more importantly, where should I begin looking, if
> I want to introduce something similar to #cs , let's say #ls for layout
> sensitive? Can I do this by modifying the read tables, or I need to go
> the full monty and implement a new lexer (I hope not)?
> 
> Vlado

Here's what I did decades ago in a Lisp dialect:

  When the last element of a list is itself a list, I placed a slash in 
front of it and deleted the parenteses around the inner list.

This was enough to eliminate almost all bracket counting.

(a b c / d e f / g h i)

instead of

(a b c ( d e f ( g h i)))

and it allowed a few syntacitc differences.
For example I used
   (let a b)
instead of
   (let ((a b)))

(I forget just how many parentheses Scheme uses here)
.

So in a series of let's I could write

  ( let a b 
  / let c d
  / let e f
  / onion a c e
  )

or an if-chain
  ( if a b
  / if c d
  / let e (foo)
  / if e joo
  / alt a c
  )

Very convenient notation.

-- hendrik


Posted on the users mailing list.