[plt-scheme] Bad interaction w/Unix

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Fri May 18 12:25:36 EDT 2007


On Fri, 18 May 2007, Robby Findler wrote:

> It is not a paren problem.
>
> The name of the module (its second argument) must be the same as the
> name of the file. So, change "client" to "md5" or change the filename
> "md5.sh" to "client.sh".

Hi SpinyNorman,


One other thing to fix, though: make the call to "md-port-chunks" the last 
expression within the module, rather than an expression outside the module 
declaration.

Putting it outside won't work too well since mzscheme in '-u' 
module-running mode expects only a single module declaration within the 
shell script.  So:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module md5 mzscheme
   (require (lib "md5.ss"))

   (define test-string (make-string 100000))
   (define (md-port-chunks port chunk-size)
     (let loop ()
       (begin
         (display (md5 (read-bytes chunk-size port)))
         (newline))
       (if (not (eof-object? (peek-byte port)))
           (loop))))

   (md-port-chunks (open-input-string test-string) 1024))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


It'll be ok that your module is called 'md5' and yet still use the 
standard library "md5.ss".  There's no name conflict here since the 
standard library collections are identified with a '(lib "...")' thing. 
(I'm mentioning this because this isn't necessarily true in some other 
module systems in languages like Python.)


You'll probably want to update your program later to work with the command 
line.  Command line arguments live in the "current-command-line-arguments" 
parameter.  You might also want to search Help Desk for "cmdline", which 
offers a command line parser.


Posted on the users mailing list.