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

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Thu Dec 10 11:53:44 EST 2009

As far as my beginning students are concerned, "and" and "or" are  
functions with contract
Boolean Boolean ... -> Boolean
They happen to be "smart" about their arguments, not bothering to  
evaluate the later arguments if the earlier arguments answer the  
question.

But in fact, they're implemented as macros or special forms.  (Is  
there a difference between a macro and a special form?)  Which makes  
no difference in BSL, BSLLA, or ISL, but once we get to ISLL, it  
makes a difference: one cannot pass "or" or "and" as arguments to a  
function that expects a function.

Is it feasible for a function in (say) ISLL to refer to a function  
whose definition is in a module written in Lazy Scheme?  If so, would  
it be reasonable to define "and" and "or" that way, so they could be  
passed around as functions?

Failing that, would it be reasonable to define "and" and "or" in such  
a way that if they appear other than in function-call position, they  
evaluate to a function that does the right thing, so again they could  
be passed around as functions?


Stephen Bloch
sbloch at adelphi.edu



Posted on the users mailing list.