[racket-dev] P4P: A Syntax Proposal

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Wed Jul 28 18:43:42 EDT 2010

Everett wrote at 07/28/2010 06:06 PM:
>   (map (lambda (x) ...) 
>        lst)
> is more readable in the Ruby form:
>   map(lst) {|x| ... }
> or even in Javascript with Prototype:
>   lst.each(function(x) {
>     ...
>   });

I'll respectfully differ with that last assertion.

In my JavaScript experience the last couple years (with plain, jQuery, 
Dojo, and AIR), subjectively speaking, that boilerplate syntax quickly 
gets unreadable once you start nesting syntax nontrivially.  And nesting 
is commonplace when you're doing normal real-world AJAX-y things like 
finding a DOM element to attach a callback that does asynchronous 
XmlHttpRequest that has a completion callback that checks some status 
and conditionally iterates over some DOM query to apply some 
transformation...  Even without Scheme syntax extension to simplify 
things, the simple economizing of typing "))))" instead of "});});" 
would help, IMHO.

Here's a real-world example that I blogged earlier this year: I had just 
then typed the line of code "annosJson);});}});}".  (That break in the 
pattern is intended.)  Actually, I had typed that with JavaScript 
idiomatic line breaks and indentation before, and I felt it was even 
harder to get right and read with the line breaks.  In Scheme, I 
would've just hit ")" until paren-matching showed that I'd closed the 
syntax to the desired level.  And then the conventional Lisp-y 
indentation and/or paren highlighting would've made the code more 
'visual' than the JavaScript.  Again, IMHO.

Regarding the IMHOs, someone roll out the gaze trackers and brain MRIs 
already. :)


Posted on the dev mailing list.