[racket-dev] P4P: A Syntax Proposal

From: Everett (webj2 at unoc.net)
Date: Wed Jul 28 17:57:30 EDT 2010

@Jos
I believe the idea was not to convert people who like s-exprs but rather
to attract all those other programmers (including beginners) who don't
like them.  (It might also help convince older CS dept people to allow
changing the intro CS course to H2DP using a non-parenthesis syntax.)

@Shrirm
I don't understand why not write a lexer, since replacing "do: ()" with
"{}" is the most natural and readable thing to do.  It also would allow
"when:" to expect one argument by default since "when: {}" is easy to
write. (Whereas the current proposal is to make when: be a do:-style
construct since writing "when: do: ()" is a bit much.)  If you wish to
encourage placing the closing paren/curly-brace on it's own line then
use curly-braces because that is what people are used to doing.  It
takes advantage of pre-formed associations.  Parens mean expression
grouping or function application, curly-braces mean blocks of code or
definition structure.

Infix notation can be achieved unambiguously if you use LL(1) with
backtracking instead of just LL(1) by accepting expressions in the form
"(a b c)" that become "b(a, c)".  This is unambiguous only if you do not
allow including useless parenthesis around expressions, since if you
could add in arbitrary parens you could write "(a (+) (c))" which could
be the expression "a[+](c)" or could be "(a + c)" -> "+(a, c)". Usually
extra parens are not allowed in Racket, but I wasn't sure if you kept
the same restriction.  I have been using this idea in a syntax I'm
experimenting with, but the idea of allowing infix by forcing
parenthesis to solve associativity/precedence was stolen from Niel
Toronto.

Did the proposal address how quoting/unquoting could be done on P4P
syntax (for macros, etc.), or how to make a list?  I suppose "list(a, b,
c)" would work, but do we not have "'(a, b, c)" or something too?

-Everett

On Wed, 2010-07-28 at 22:00 +0200, Jos Koot wrote:
> With a good editor, like that of DrSceme, pardon me, RdRacket, I experience
> no difficulty at all with parentheses. In fact I hardly see them. DrRacket
> shows me the extent of a subsexpr very micely. I would have, may be, a
> problem when parsing symbolic expressions lacking parenteses, unless, of
> course, reading a sexpr with omission of unecessary parentheses would give
> me an old fashioned parenthesized sexpr. I am not convinced, yet ...
> Jos
> 
> > -----Original Message-----
> > From: dev-bounces at racket-lang.org 
> > [mailto:dev-bounces at racket-lang.org] On Behalf Of Shriram 
> > Krishnamurthi
> > Sent: 28 July 2010 19:45
> > To: PLT Developers
> > Subject: [racket-dev] P4P: A Syntax Proposal
> > 
> > I've been vexed for a while about parenthetical syntax: I 
> > love it, appreciate what it offers, but also recognize that 
> > no amount of teaching or arguing alters how people perceive 
> > it.  With the switch to Racket, and our continuing interest 
> > in user interface issues, I believe it is wise to consider an 
> > optional alternate syntax.
> > 
> > I finally had a breakthrough last weekend on how to create a 
> > syntax that may be more palateable without losing the essence 
> > of parenthetical syntax.  As a preview, it does incorporate 
> > indentation, but in a good way.  You'll see.
> > 
> > Feedback welcome.  The most important is whether you spot any 
> > flaws regarding predictable parsing.
> > 
> > Here's a *non-permanent* URL where you can learn more:
> > 
> >   http://www.cs.brown.edu/~sk/tmp/P4P/
> > 
> > Shriram
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://lists.racket-lang.org/listinfo/dev
> 
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/dev



Posted on the dev mailing list.