[plt-scheme] macros, special forms, and lazy functions

From: Prabhakar Ragde (plragde at uwaterloo.ca)
Date: Sat Dec 12 12:16:45 EST 2009

Stephen Bloch wrote:

> The classroom use-case I'm thinking of is "I assign a bunch of  
> functions on lists, which can be written from scratch using  
> recursion, or more briefly using standard higher-order functions like  
> map, filter, foldr and foldl, etc."
> The following problems would fit naturally into this use-case, and  
> they have obvious definitions, but the fact that "and" and "or" are  
> special forms means that the obvious definitions don't pass a syntax  
> check.

When I introduce `and' and `or', I emphasize that they are special forms 
like `define' and `cond', and not functions, and I show them examples of 
where the short-cutting makes a difference.

(or true (= (/ 1 0) 1))

They don't seem to have any trouble with wanting to pass them as 
parameters to higher-order functions later on. I do remind them at that 
point and mention andmap/ormap.

I can check with the people teaching our non-major sequence based on 
HtDP, but I don't think they've reported any problems, either. --PR

Posted on the users mailing list.