---
slug: 10-syntax
title: Syntax
description: Synsema syntax — variables with let/set, operators, the unary pipe, inline conditionals, strings, and indentation blocks.
example_ids: [syntax]
---

# Syntax

Synsema reads like prose. Blocks are defined by **indentation** (4 spaces or 1 tab) — there are no curly braces.

> Coming from Python? Read [Python → Synsema — the translation table](/en/0.6.x/01a-python-to-synsema)
> first — it maps the Python reflexes to these forms and flags the semantic traps (doctested).

```synsema
-- Doc example: core syntax. Universal code; English comments.
intent: "doc example: variables, operators, pipe, inline conditional"

task double(n)
    give n * 2

print("5 |> double = " + text(5 |> double))    -- run shows: 5 |> double = 10

test "let / set / arithmetic"
    let x be 10
    set x to x + 5
    assert_eq(x, 15)
    assert_eq(10 % 3, 1)

test "comparison + boolean logic"
    assert(1 < 2 and 2 <= 2)
    assert(true or false)
    assert(not false)

test "pipe is unary application: x |> f == f(x)"
    assert_eq(5 |> double, 10)

test "inline conditional is an expression"
    let label be when 80 >= 50 then "pass" otherwise "fail"
    assert_eq(label, "pass")
```

## Variables

`let name be value` introduces a binding; `set name to value` reassigns it.

## Operators

- Arithmetic: `+` `-` `*` `/` `%` `**`. **Division is always float** (`10 / 3` → `3.333…`).
- Comparison: `==` `!=` `<` `>` `<=` `>=`.
- Logic: `and` `or` `not`. **`and`/`or` short-circuit** (engine v0.6.10+): `contains(m, "k") and m["k"] == 1` is a valid guard — the index does not run when `contains` is false, and `or` skips its right side when the left is already true. The result is always a **bool**, never the operand: `x or "default"` is `true`/`false`, not the default (use `when`). On engines ≤ 0.6.9 both sides always evaluated — guard with a nested `when` there.
- **Pipe `|>` is unary application**: `x |> f` means `f(x)` (where `f` is a task name or a one-argument lambda). For multiple args, wrap it: `xs |> ((v) => f(v, extra))`.

## Inline conditional

`when cond then a otherwise b` is an **expression** (usable inside `let`, a map, or a call), distinct from the `when` block statement.

## Strings

- `"..."` / `'...'` — single-line, with escapes (`\n`, `\t`, `\"`). A literal newline inside is an error.
- `` `...` `` — multiline + interpolation: `` `Hello {name}` `` evaluates `{expr}`. Ideal for SQL/HTML.

## Comments

`-- a comment` runs to end of line.
