[plt-scheme] question from a newbie regarding the import of a library

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Sun Apr 5 14:30:26 EDT 2009

Jon Loldrup wrote:
> 2009/4/5 David Van Horn <dvanhorn at ccs.neu.edu <mailto:dvanhorn at ccs.neu.edu>>
>     Jon Loldrup wrote:
>         Well it sure does evaluate successfully now, and testing the
>         first 4 expressions on page 4 in "The Reasoned Schemer" makes
>         them all return the same value as the ones in that book. Only
>         thing is, the book doesn't mention the definitions of fail and
>         succeed (only that they are longs for #u and #s), so I'm not
>         sure whether this solution is some crude hack or the official
>         way to do it.
>     The book gives definitions of #s and #u, both in English and Scheme.
>     See the code at the end of the book.  The definitions you gave are
>     equivalent, so this is no crude hack.
> That doesn't make sense in my mind: If #u and #s are actually defined 
> how come I can't use them and have to use the longs "fail" and "succeed"?
> eg.:
> the line
> (run #f (q) #u (== #t q))
> results in
> Module Language: invalid module text
> read: bad syntax `#u'

The book gives definitions in the sense that it tells you what the 
meaning of these things are.  The book also gives definitions in the 
sense that it provides Scheme code representing this meaning.

You are correct that you cannot use #u and #s directly (remember that #u 
and #s are written `fail' and `succeed', as stated p3).  These are 
notational shorthands used for the purpose of presentation in the book. 
  You cannot, in any standard way, define such constants since it would 
involve extending the concrete syntax of Scheme.  However, you can bind 
the names `fail' and `succeed' to the meaning #u and #s.

The code you are using does not provide such bindings, however since you 
know the meaning, it is easy to create such bindings yourself.

To say that the book does not mention the definition of fail and succeed 
is clearly incorrect.  It does.  You asked whether the definitions you 
provided were some crude hack or the official way to do it.  If you can 
convince yourself that the meanings you assigned fail and succeed are 
equivalent to those given in the book, the answer is no, it is not just 
a crude hack.


Posted on the users mailing list.