[racket] Sweet expressions; or making it easier to introduce Racket to me and my coworkers :-)

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Jul 21 09:25:00 EDT 2011

On Jul 21, 2011, at 6:44 AM, Stephen Bloch wrote:

> Right.  Nested conditionals and loops in Racket are no more syntactically painful than nested conditionals and loops in Java/C/C++, if you put braces around the bodies.
> ( if ( > x y ) (+ x 3 ) ( * 4 y ) )
> if ( x > y ) { x = 3 ; } else { y = 4 ; }

You don't have to go non-idiomatic in Racket to approximate 
the non-nesting, step-by-step style of C, Java, and such languages. 

Now that define is legal in many places, just give names to 
intermediate results. More generally, here is a conjecture 
about the psychology of programming: 

 people take to programming in C more easily than 
 to algebra because they can 'store' intermediate 
 results in 'registers' and take a break to contemplate
 what to do next. 

Warning: this is an untested conjecture by a guy who has 0 
background in psychology or how to conduct an experiment. 
All of this is based on observations. 

-- Matthias

Posted on the users mailing list.