[racket] A VAT calculator using Racket web server

From: Noel Welsh (noelwelsh at gmail.com)
Date: Mon Sep 6 08:05:38 EDT 2010

I made some brief notes, which I reproduce below ('cause I'm too lazy
to write them out again):

;; NHW
;; This function is odd. Its type is
;;  (U Number String) -> (U Number String)
;; which is almost certainly not what you want.
(define (as-number x)
 (if (number? x)
     x
     (safely (string->number x))))

;;; STATE is whatever we choose to manage outselves, in whatever form.
;; NHW
;; Nope. State is a list with at least two elements. If it ain't,
calculating amount and rate will cause errors.


On Mon, Sep 6, 2010 at 11:48 AM, Mark Carter <mcturra2000 at yahoo.co.uk> wrote:
> The questions I'd like to ask specifically at this point are:
> * should state (in my case the user's input for amount and tax rate) be passed
> as a separate parameter in the function definition, or is it better to pack it
> in with the request?

I don't quite understand the question. Should state be separate
parameter to vat-page? Yes, it is much clearer if it is. While you're
at it, split out amount and rate into two parameters. vat-page makes
no use of the request, anyway.

> * is there a better way of writing button-clicked? The function is doing a lot
> of work of hand-decoding the request and repacking it - that seems inelegant

You might be interested in formlets.

> * I'm a little puzzled as to what the deal is with the parameter make-url. I'm
> thinking that has something to do with creating the "continuation" behind the
> scenes??

Yeah. IIRC, the continuation ID is not know till you start sending the
response (i.e. call send/suspend or variants) so you can't embed any
callback URLs till that time. make-url generates the URLs.

HTH,
N.


Posted on the users mailing list.