- Lexical structureSource spellings, reserved and contextual words, comments, line breaks and diagnostic positions.
- Literals and templatesLiteral spellings, values, string interpolation, and tagged templates.
- TypesDefines type forms, compatibility, and shared inference rules.
- Bindings and scopeDefines how names are introduced, resolved, and reassigned.
- Expressions and operatorsDefines expression formation, grouping, and operator behavior.
- Functions and genericsFunctions relate parameter types, a body, and a result type. A named function can declare type parameters and require protocol bounds.
- Records, enums and newtypesDeclare data types, construct their values, and check record updates and generic construction.
- Protocols and implementationsDeclare protocol requirements, provide implementations, and understand conformance, receiver methods, and resource bindings.
- Pattern matchingDefines patterns, matching, and accepted matches.
- Collections and comprehensionsChoose collection construction forms and check the rules for literals, array spread, and comprehensions.
- Blocks and control flowBlocks group execution and produce final values. Conditional branches, loops, explicit transfers, and deferred actions determine which code runs next.
- Failure and propagationRead and check functions that forward Result errors with postfix
?. - Modules and visibilityUse this page to split a source program into files and choose which declarations other files can access.
- ConcurrencyWrite and check concurrent expressions with this reference. The examples cover result fields, duration spellings, and rejected forms.
- Derived Show outputUse derived Show to inspect record values. The output includes the record name, declared fields, and rendered field values.
Language
Read syntax and language rules in order.