:sig
function string(value : as string, opt : dval = {}) string

:params
value : scalar value or text to convert
opt : options map with `fallback`

:returns
The converted text, or `opt.fallback`.

:content
`string()` reads a scalar as text. Request values are `dval`, so this is the normal way to read request fields.

`value` accepts scalar values through `as string`. The conversion keeps source text exact. Text returns unchanged. Numbers use exact round-trip text. Booleans become `true` or `false`.

`opt.fallback` is the result for empty text or a value with no text form. It defaults to the empty string. Empty and missing `dval` values both convert to empty text. Use the `?` suffix before conversion when presence matters. `value?` is false for a missing value and true for an empty value.

The options map accepts only `fallback`. An unknown key, including `base`, is an error.

## The other converters

All numeric constructors use the same `value, opt` shape. Integer constructor options also support `base`. `bool()` keeps a `dval` first parameter, because strings cannot be conditions.

:example capy render
print(string(dval(42)), "\n")

:example capy render supply a fallback for an absent key
print(string(request.query.name, fallback: "guest"), "\n")

:example capy render distinguish absent from empty
if request.query.q? {
    print("searched: ", string(request.query.q), "\n")
} else {
    print("no search term\n")
}

:example capy render read a value returned by another unit
var target := unit_load("/tests/capy-module-target.capy")
print(string(target.echo(name: "Ada").name, fallback: "unknown"), "\n")

:see-group
constructors

:see
