# Syntax quick reference

> Find common Alice syntax and jump to its complete explanation.

Canonical: https://alice-lang.org/documentation/reference/syntax/

[Documentation index](https://alice-lang.org/documentation/llms.txt) · [Complete book](https://alice-lang.org/llms-full.txt)

Use this page to locate a form you already recognize. The linked chapters explain semantics, limits, and examples.

## Values and flow

| Form                                                | Read more                                                                                          |
| --------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `x = 1`, `x : Int64 = 1`, `val x = 1`               | [Variables](https://alice-lang.org/documentation/language/variables.md)                            |
| `String?`, `nil`, `value.nil?`, `value&.member`     | [Types and nil](https://alice-lang.org/documentation/language/types.md)                            |
| `[1, 2]`, `{"a" => 1}`, `%w[a b]`, `:name`          | [Literals](https://alice-lang.org/documentation/language/literals.md)                              |
| `1..5`, `0...n`                                     | [Ranges](https://alice-lang.org/documentation/language/literals.md#inclusive-and-exclusive-ranges) |
| `if` / `elsif` / `else` / `end`                     | [Control flow](https://alice-lang.org/documentation/language/control-flow.md)                      |
| `unless`, postfix `if`, `while`, `until`, `for`     | [Control flow](https://alice-lang.org/documentation/language/control-flow.md)                      |
| `break`, `next`, `return`                           | [Early exits](https://alice-lang.org/documentation/language/control-flow.md#break-next-and-return) |
| `begin` / `rescue e : Exception` / `ensure` / `end` | [Exceptions](https://alice-lang.org/documentation/language/exceptions.md)                          |

## Definitions and behavior

| Form                                                    | Read more                                                                                                                                |
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `def name(x : T) : R ... end`                           | [Methods](https://alice-lang.org/documentation/language/methods.md)                                                                      |
| `def name(x : T) = expression`                          | [Endless definitions](https://alice-lang.org/documentation/language/methods.md#definition-and-return-value)                              |
| `call { \|x\| ... }`, `do \|x\| ... end`, `yield`       | [Blocks](https://alice-lang.org/documentation/language/blocks.md)                                                                        |
| `->(x : T) { ... }`, `lambda`, `proc`, `&:name`         | [Lambdas](https://alice-lang.org/documentation/language/blocks.md)                                                                       |
| `class`, `struct`, `record`, `record struct`            | [Objects](https://alice-lang.org/documentation/language/classes.md), [records](https://alice-lang.org/documentation/language/records.md) |
| `getter`, `property`, `@field`, `initialize`            | [State and construction](https://alice-lang.org/documentation/language/classes.md)                                                       |
| `module`, `include`, `extend`, `using`                  | [Modules](https://alice-lang.org/documentation/language/modules.md)                                                                      |
| `class Box(T)`, `forall T where T : IComparable(T)`     | [Generics](https://alice-lang.org/documentation/language/generics.md)                                                                    |
| `enum Shape`, `case ... when`, `case ... in`            | [Patterns](https://alice-lang.org/documentation/language/pattern-matching.md)                                                            |
| `send`, `respond_to?`, `define_method`, `instance_eval` | [Dynamic and DSLs](https://alice-lang.org/documentation/language/dynamic.md)                                                             |

## Host and concurrency

| Form                                                 | Read more                                                                                                |
| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `require "./file"`, `namespace`, `using System.Text` | [Program structure](https://alice-lang.org/documentation/language/programs.md)                           |
| `Type.new`, `.NETMember`, `ref`, `out`               | [.NET interop](https://alice-lang.org/documentation/guides/dotnet.md)                                    |
| `@[Name(args)]`, `lib`, `fun`                        | [Attributes](https://alice-lang.org/documentation/language/attributes.md)                                |
| `spawn { ... }`, `async def`, `await`                | [Tasks](https://alice-lang.org/documentation/concurrency/tasks.md)                                       |
| `Channel(T)`, `Actor(T)`                             | [Messaging](https://alice-lang.org/documentation/concurrency/channels.md)                                |
| `Mutex(T)`, `Atomic`                                 | [Synchronization](https://alice-lang.org/documentation/concurrency/synchronization.md)                   |
| `@[SoA]`, `SoA(T)`                                   | [Columnar records](https://alice-lang.org/documentation/language/records.md#structure-of-arrays-records) |

For an unfamiliar error code, use the [diagnostic reference](https://alice-lang.org/documentation/reference/diagnostics.md). For a command, use the [CLI reference](https://alice-lang.org/documentation/tools/cli.md).

## Continue reading

- Previous: [Feature status and boundaries](https://alice-lang.org/documentation/reference/feature-status.md)
