[racket] Nested scope in D vs Racket

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Sat Aug 21 07:39:12 EDT 2010

On Aug 21, 2010, at 3:32 AM, Eduardo Cavazos wrote:

> (let ((a 20))
>   (let ((a 30))
>     ...))
>
> It sounds like the D designers are "protecting" the programmers.  
> The Racket team is of course concerned with the "teachability" of  
> their languages and have experience with the known pitfalls in  
> languages. So my question is, do any Racket people agree with the  
> rationale provided by the D guys? In all your years of teaching  
> Scheme/Racket, has this situation of shadowing names been a  
> problem? (I've always seen it as a feature, even C supports it.)

Nested scope isn't allowed in Beginning Student Language (since there  
is no "let" or "local" at all -- all definitions are at the top level).

Wait: that's not quite true.  In Beginning Student Language, you can  
define a function with parameters whose names shadow a global  
variable.  This is just an instance of the more general phenomenon  
that parameter names in a function have no interaction with names  
anywhere outside that function, and students don't seem to have much  
trouble with it in practice.

Later on, when they get "local" and "let", they have enough  
programming maturity to handle the shadowing phenomenon you describe.

Stephen Bloch
sbloch at adelphi.edu



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100821/5e8dc716/attachment.html>

Posted on the users mailing list.