Variables and Data Types
Devlish variables hold numbers, strings, booleans, null, records, or lists. Variables are created by assignment and do not require type annotations.
Primitive Types
Section titled “Primitive Types”# Numbers (integers and decimals)count equals 42rate equals 0.15
# Strings (double-quoted)name equals "Solar Project Alpha"
# Booleansis_active equals truehas_errors equals false
# Nulllegacy_field equals nullVariable Naming
Section titled “Variable Naming”Write multi-word names naturally. Devlish normalizes them to snake_case.
contract value equals 500000# Internally stored as contract_value
total exposure equals contract_value plus deductibleFor extracted variables, use explicit snake_case in save as:
Find liability cap and save as liability_capRecords
Section titled “Records”Create structured data with named fields using record with.
invoice equals record with 1200 as amount and "pending" as statusproject equals record with "Solar Farm" as name and 5000000 as value and true as activeCreate ordered collections with list of.
statuses equals list of "approved", "pending", and "rejected"scores equals list of 85, 92, 78, and 95Accessing Record Fields
Section titled “Accessing Record Fields”Use field of record syntax to read a field value.
invoice_amount equals amount of invoiceproject_name equals name of projectNested access chains naturally:
city equals city of address of customerMissing fields return nil rather than causing an error.
Setting Record Fields
Section titled “Setting Record Fields”Use Set to mutate a field in place.
Set amount of invoice to 1300Set status of project to "complete"Nested updates create intermediate records if they do not exist:
Set city of address of customer to "Austin"Record Keys and Values
Section titled “Record Keys and Values”Extract structure from records:
invoice_keys equals keys of invoiceinvoice_values equals values of invoiceinvoice_entries equals entries of invoiceRecord Shape Validation
Section titled “Record Shape Validation”Check that a record has expected fields or matches a type shape:
Require invoice has fields amount, customer
invoice_shape equals record with "number" as amount and "text" as customerRequire invoice matches shape invoice_shapeShape values use type names: text, number, boolean, list, record, any.
Type Checking
Section titled “Type Checking”Inspect the type of any value at runtime:
value_type equals type_of invoice# Returns "record", "list", "number", "text", "boolean", or "null"