[plt-scheme] questions about modules and keyword arguments and so on
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.
This:
(define (dispatch-mvc conn req)
(output-response
conn
(eval (cdr (assoc (url->string (request-uri req)) routes)))))
Can become this:
(define (dispatch-mvc conn req)
(output-response
conn
(let ([the-function (cdr (assoc (url->string (request-uri
req)) routes))])
(the-function)))
That you used eval here suggests you haven't yet fully grasped how to
use higher order functions.
HTH,
Noel