[plt-scheme] When is (required ...) required in a formlet?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sun Apr 25 01:14:18 EDT 2010

text-input and password-input are returned (formlet/c (or/c false/c binding?))

This means that they can result in a form binding (if the input was
entered) or #f if it wasn't.

required turns a (formlet/c (or/c false/c binding?)) into a (formlet/c bytes?)

This means it extracts the form binding value or error if the field
wasn't entered.

to-string turns a (formlet/c bytes?) into a (formlet/c string?)

You never "need" required, but if you use to-string, then the types
must match and required is often useful for that.


On Sat, Apr 24, 2010 at 9:16 PM, Todd O'Bryan <toddobryan at gmail.com> wrote:
> I just discovered that this formlet
> (define login-formlet
>  (formlet
>   (div "Username:" ,{(to-string (required (text-input))) . => . username} (br)
>      "Password:" ,{(to-string (required (password-input))) . => . password})
>   `#hash((username . ,username)
>          (password . ,password))))
> doesn't work if I remove the (required ...) wrapping (text-input) and
> (password-input).
> I'm fine with that, but I don't really understand what it's doing and,
> therefore, when I have to include it. Any insight?
> Todd
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

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

Posted on the users mailing list.