[plt-scheme] language levels in drscheme

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Wed Jan 17 15:35:33 EST 2007


On Wed, 17 Jan 2007, Danny Yoo wrote:

> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (module test-lang (lib "plt-pretty-big.ss" "lang")
>  (define (hypotenuse a b)
>    (sqr (+ (sqrt a) (sqrt b)))))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Hi Corey,

Oh good grief, that's not the definition of the hypotenuse function... 
*grin*  Sorry about that.


But I wanted to add that if you have this as a file, you can then invoke 
it by using REQUIRE.  You'll also probably want to expose the contents of 
the module to the outside world, which is done by using the PROVIDE form.

So, for example:

########################################################################
dyoo at dyoo-desktop:~$ cat test-lang.ss
(module test-lang (lib "plt-pretty-big-text.ss" "lang")

   (provide (all-defined))

   ;; hypotenuse: number number -> number
   ;; Computes the hypotenuse of a right triangle with legs a and b.
   (define (hypotenuse a b)
     (local ((define a*2 (sqr a))
             (define b*2 (sqr b)))
       (sqrt (+ a*2 b*2)))))


dyoo at dyoo-desktop:~$ mzscheme
Welcome to MzScheme v369.4 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
> (require "test-lang.ss")
> (hypotenuse 3 4)
5
########################################################################


Finally, have you already seen these?

     http://www.htus.org/Book/Staging/how-to-use-modules/

     http://hkn.eecs.berkeley.edu/~dyoo/plt/modules.text


Hope this helps!


Posted on the users mailing list.