Values that may be missing
There is no null or undefined. A type followed by ? may hold none,
and reading it means handling both cases, usually with
match.
Writing another language's form is an error with an edit that writes the
Jadpo form: null, nil, undefined and None are each
type.foreign_value, and ?? and ?. are syntax.null_coalescing and
syntax.optional_chaining, whose edits write the match.
type Listing = Object { name: ProductName subtitle: ProductName?}function headline(listing: Listing) -> ProductName { return match listing.subtitle { some(subtitle) -> subtitle none -> listing.name }}
A field that may be none must still be given: a Listing must say
subtitle: none explicitly. Being allowed to leave a field out is a separate
idea, and only an Input has it:
type ListProducts = Input { name: ProductName { optional: true } page_size: PageSize { default: 25 }}type RenameProduct = Input { name: ProductName subtitle: ProductName? { default: none }}
optional: truelets the request leave the field out. Reading it givesT?, and a field left out reads asnone. Only an update'spatch:tells "left out" apart from "sent asnone" (Reads and writes).default: 25fills in a value when the request leaves the field out, checked against the field's rules while compiling.default: nonefills innonefor a field that may benone.
A value that may be none widens as the value itself does: a
Customer.email? can be used where an Email? is expected.
Markdown for agents: /docs/absent-values.md.Built from Jadpo main at a707efb.