[plt-scheme] questions about modules and keyword arguments and so on

From: Noel Welsh (noelwelsh at gmail.com)
Date: Thu Jul 10 05:12:04 EDT 2008

On Thu, Jul 10, 2008 at 2:06 AM, Tyler McMullen <tbmcmullen at gmail.com> wrote:
> However, my point was not that I need to accomplish this particular task.
> Rather, I'm stumped trying to figure out what is wrong with the quoted
> code.  If anyone has some insight into that... It would be greatly
> appreciated.

Ok, you prompted me to get off my lazy arse and actually read your code.

The essential error is, I think, that you're using the mzscheme
language not the scheme/base language.  Use modules for *all* of your
files and start them with

  #lang scheme/base

rather than

  (module name mzscheme ...

and get rid of the closing ) as well.

The keyword issue is an incompatibility between the v3 legacy language
and the v4 language and is documented in the release notes (at least,
it should be...)

Also, you don't need that eval.  For a beginner you can't really go
wrong *never* using eval.  I'm serious here -- experienced Schemers
very rarely use it, and beginners use it far too much.


(define (dispatch-mvc conn req)
            (eval (cdr (assoc (url->string (request-uri req)) routes)))))

Can become this:

(define (dispatch-mvc conn req)
            (let ([the-function (cdr (assoc (url->string (request-uri
req)) routes))])

That you used eval here suggests you haven't yet fully grasped how to
use higher order functions.


Posted on the users mailing list.