[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Simple drawing vs. Advance Student



David Skoupil wrote:

> Than we asked the students to modify their programs to use internal
> definitions. Oops. Advance student language does not support internal
> definitions and draw.ss teachpack does not work under Full Scheme because
> the procedure make-posn does not exist here. Is there a way out of it? Can I
> enjoy having both a simple drawing interface and internal definitions?

The simple way out of this is to use the LOCAL construct in the
Advanced Student language.  You will find documentation on LOCAL in
the Help Desk.  LOCAL, a PLT Scheme addition, is a superior
alternative to internal definitions because it preserves the top-level
definition semantics in the internal context, whereas internal defines
do not, which can lead to some very tricky errors if the students rely
on the top-level semantics more than they realized.

As a simple illustration, if you have

(define a ...)
(define (b x) ...)
(define-struct c (...))
<expression>

you can instead write

(local [(define a ...)
	(define (b x) ...)
	(define-struct c (...))]
  <expression>)

ie, just wrap a pair of parens around the definitions you wish to
localize, and add the keyword LOCAL.

Cheers,
Shriram