[racket] novice question about parentheses and control flow

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Dec 12 10:29:32 EST 2012

In Racket, Scheme, and Lisp, parentheses are NOT optional, they are meaningful. Everyone counts. Once you have programmed in this world for a while, however, you won't really see the parens anymore and you won't make nearly as many syntax mistakes as in 'ugly languages'. 

Feel free to ask more on this list -- Matthias




On Dec 12, 2012, at 10:25 AM, je back wrote:

> There's something quite basic about how scheme works that eludes me.  Please let me know if it would be more appropriate to post this somewhere eles.
>  
> This program works as I expect:
>  
> (let loop ((a  0))
>   (if (> a 3)
>       (print "it's over")
>       (begin (print a)
>              (loop (+ 1 a)))))
>  
> If add an extra set of parentheses around the begin clause:
> 
> (let loop ((a  0))
>   (if (> a 3)
>       (print "it's over")
>       (begin ((print a)
>              (loop (+ 1 a))))))
>  
> I get the following (from DrRacket 5.3.1) :
> 0123"it's over". . application: not a procedure;
>  expected a procedure that can be applied to arguments
>   given: #<void>
>   arguments...:
>    #<void>
>  
> I don't understand how adding the extra parentheses caused the change in behavior.
>  
> Thanks,
> Jan Erik
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.