[racket] novice question about parentheses and control flow

From: je back (jeback1 at gmail.com)
Date: Wed Dec 12 13:03:22 EST 2012

Thanks for the explanation; it makes sense now.  Part of my confusion
stemmed from not recognizing that the calls were stacking up until the eof
condition was met.
Jan Erik


On Wed, Dec 12, 2012 at 11:49 AM, Stephen Bloch <sbloch at adelphi.edu> wrote:

>
> On Dec 12, 2012, at 10:29 AM, Matthias Felleisen wrote:
>
> > In Racket, Scheme, and Lisp, parentheses are NOT optional, they are
> meaningful. Everyone counts.
>
> In specific, one of the things parentheses often mean is that the first
> thing inside the parentheses is a function to be applied to the remaining
> things.
>
> In your example,
> ... (begin ((print a) (loop (+ 1 a))))
> you're basically asking Scheme to use the result of (print a) as a
> function which it can then apply to the result of (loop (+ 1 a)).  Since
> (print a) doesn't return any result at all, it certainly doesn't return a
> function that can be called on something else.
>
> What you're running into is a common problem for students moving from high
> school algebra to Lisp/Scheme/Racket: in high school algebra, MISSING
> parentheses can sometimes give you wrong answers due to order-of-operations
> errors, but EXTRA parentheses can never hurt.  In Lisp/Scheme/Racket,
> either one can hurt.
>
> Stephen Bloch
> sbloch at adelphi.edu
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121212/38057672/attachment.html>

Posted on the users mailing list.