[plt-scheme] Formlets in PLT

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Sep 25 11:54:58 EDT 2008

Michael,

I haven't spent a lot of time using formlets just yet. They seem to me
to be quite elegant in their terseness and ability to hide a lot of
annoying details, like generating names and composing conversion
routines. I certainly will not argue that they are "the one true way"
to deal with forms.

The way I look at it is that they standardize a whole bunch of code
I've been copying every time I start a new Web app. If your tools are
equally powerful, I would not advocate change. If yours are more
powerful, maybe we can improve formlets? [Obviously being class-based
adds a lot, but I'm wondering at what cost in simplicity.]

Basically, I don't want to argue either way, but I don't want to
ignore your email. =)

Jay

On Thu, Sep 25, 2008 at 9:37 AM, Michael Forster <mike at sharedlogic.ca> wrote:
>
> On 16-Sep-08, at 5:59 PM, Jay McCarthy wrote:
>
>> The Links group has created formlets:
>>
>> http://groups.inf.ed.ac.uk/links/formlets/
>>
>> I have spent the afternoon implementing formlets in PLT.
>> --
>>
>
>
> Interesting, and I'm delighted to see that PLT Scheme developers won't
> hesitate
> to 'push the envelope'.
>
> However, as a commercial developer writing and delivering applications with
> PLT Scheme, I wonder what are the advantages of the formlet approach
> compared
> to the typed interactions approach described in the HTDP extended exercise,
> "Interacting on the Web."  Specifically, if one revises (as I have, snippets
> below)
> the latter to use PLT class-based input fields to permit more convenient
> inheritance
> and composition, then it, too, would seem to address the problems targeted
> by
> formlets:
>
> - static association between form and handler
> - processing of raw HTML strings into structured values
> - composition, involving fresh eld names at runtime
>
>
> (define input%
>  (class object%
>    (init-field prompt)
>    (init (value #f))
>    (define _value value)
>    (super-new)
>    (define/public (generate name value)
>      `(input ((name ,(symbol->string name)
>                    (type "text")
>                    (value ,value)))
>    (define/public (extract name binding)
>      (and (exists-binding? name binding)
>                (extract-binding/single name binding)))
>    (define/public (type? value)
>        (string? value))))
>
> (define boolean-input%
>  (class input%
>   ...))
>
> (define string-input%
>  (class input%
>    (init (min-length #f))
>    (define _min-length min-length)
>    (init (max-length #f))
>    (define _max-length max-length)
>    ...))
>
> (define number-input%
>  (class input%
>    (init (min-value #f))
>    (define _min-value min-value)
>    (init (max-value #f))
>    (define _max-value max-value)
>    ...))
>
> (define decimal-input%
>  (class number-input%
>   ...))
>
> (define calendar-date-input%
>  (class input%
>   ...))
>
> ...
>
> (define (query names-and-inputs
>                           #:title (title "Query")
>                           #:form-generator (form-generator
> standard-form-generator)
>                           #:submit-buttons (submit-buttons (list "OK"))
>                           #:cancel-button (cancel-button "Cancel"))
>  ...)
>
>
> --
> Michael Forster
> mike at sharedlogic.ca
>
>
>
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://jay.teammccarthy.org

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.