You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a075f90
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .agents/skills/dang-language/SKILL.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,12 @@ Four ideas the rest of the language hangs on:
54
54
fields concurrently, so a field can't write state declared outside it.
55
55
-**`#` comments, no `//`**; docstrings are real `"""..."""` strings before a
56
56
declaration. Record literals use **double braces**`{{ ... }}`.
57
+
-**Strings: the delimiter decides** — `"..."`/`"""..."""` process escapes and
58
+
interpolate `${...}`; `'...'`/`'''...'''` are verbatim; backticks are raw
59
+
with `${...}`. Quotes are for text, backticks for code. Shell-ish text that
60
+
keeps `${VAR}` goes in single quotes (`'${GOBIN}:${PATH}'`, `'''sh`). Before
61
+
Dang 2.5, `"..."` doesn't interpolate and `"""` is raw. See
62
+
`reference/syntax.md`.
57
63
-**No `for`/`while` keyword** — iterate with `xs.each { x => ... }`; repeat-until-`break`
58
64
is the `loop { ... }` builtin.
59
65
-**Directives** (`@deprecated`) are typed declarations, not comment pragmas.
@@ -83,7 +89,7 @@ if (v != null) { v } else { "?" } # v narrowed to T! in the then-branch
83
89
-`xs.indexOf(x)` (nullable), `xs.flatMap { x => x.items }`, `s.toInt(base: 16)` — not hand-rolled index loops, `reduce([])` flattening or digit tables.
84
90
-`m.values` / `m.keys` — not `m.keys.map { k => m[k] }`.
85
91
- Bare `[]` / `[:]` — they infer from context (args, `??`, branches, `reduce`); no typed "empty" constants.
-`dang = "X.Y"` — the Dang version the source is written in; left out, it means the running Dang's version, and moves with each release (`dang init` pins it). Write the current syntax this skill describes. A project declaring an older version is written in that version's syntax (e.g. `for` loops, `try`/`catch`, type patterns without their `!` before 2.4): move it forward with `dang migrate` rather than mixing the two.
117
+
-`dang = "X.Y"` — the Dang version the source is written in; left out, it means the running Dang's version, and moves with each release (`dang init` pins it). Write the current syntax this skill describes. A project declaring an older version is written in that version's syntax (e.g. `for` loops, `try`/`catch`, type patterns without their `!` before 2.4, `"..."` that doesn't interpolate and a raw `"""` before 2.5): move it forward with `dang migrate` rather than mixing the two.
118
118
- One `[imports.<Name>]` per source; `<Name>` is the qualifier (`MyApi.User`). Must specify at least one of `dagger`, `schema`, `endpoint`, `service` — or `path` (native Dang module, below).
119
119
-`schema` — path to a local `.graphqls` SDL file (relative to `dang.toml`); used for type-checking and the LSP.
120
120
-`endpoint` — GraphQL HTTP URL for runtime queries; if set without `schema`, the schema is introspected (and cached) from it.
Copy file name to clipboardExpand all lines: .agents/skills/dang-language/reference/stdlib.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,12 +37,12 @@ Conversion: `toString(value)` (Dang-literal rendering of non-strings) or `value
37
37
### `String!` regex methods
38
38
Backtick templates auto-coerce to the `Regexp` scalar, so a pattern is usually `` `\d+` ``. Go `regexp/syntax` (RE2); named groups use `(?P<name>...)`.
39
39
40
-
The coercion is the literal rule (types.md): it happens where a template meets a `Regexp!` slot. A template **bound without a type** is a `String!`, so `` let re = `\d+`; s.containsMatch(re) `` is `cannot use String! as Regexp!` — annotate the binding (`` let re: Regexp! = `\d+` ``) or build it with `Regexp(...)`. `Regexp.escape(s: String!) -> String!` quotes metacharacters so arbitrary text matches literally: `Regexp(Regexp.escape(userInput))`.
40
+
The coercion is the literal rule (types.md): it happens where a template meets a `Regexp!` slot. A template **bound without a type** is a `String!`, so `` let re = `\d+`; s.containsMatch(re) `` is `cannot use String! as Regexp!` — annotate the binding (`` let re: Regexp! = `\d+` ``) or build it with `Regexp(...)`. `Regexp.escape(s: String!) -> String!` quotes metacharacters so arbitrary text matches literally: `Regexp(Regexp.escape(userInput))`. Text interpolated into a backtick pattern is spliced in as regex syntax, so escape it too: `` `^a${Regexp.escape(sep)}b$` ``.
41
41
42
42
-`.containsMatch(pattern: Regexp!) -> Boolean!`
43
43
-`.match(pattern: Regexp!) -> Match` — first match, or null
Copy file name to clipboardExpand all lines: .agents/skills/dang-language/reference/syntax.md
+23-7Lines changed: 23 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ self
37
37
38
38
## Docstrings
39
39
40
-
- A **triple-quoted**`"""..."""` string placed immediately before a declaration attaches as documentation.
40
+
- A **triple-quoted**`"""..."""` string placed immediately before a declaration attaches as documentation. Docstrings are always verbatim (no escapes, no interpolation, no language tag), and may start on the opening line.
41
41
- Works on: modules, types, fields, functions, function parameters, directives, directive args.
42
42
- This is the only docstring mechanism — there is no `///`.
43
43
@@ -61,11 +61,26 @@ greet(
61
61
-`true`, `false`
62
62
-`null` — only assignable to nullable type positions.
-**Triple-quoted**`"""..."""` — multi-line, **raw** (no escape processing), dedents by minimum indent. A leading/trailing newline adjacent to the fences is stripped (`"""\nhello\n"""` == `"hello"`). Canonical docstring form.
67
-
-**Backtick templates**`` `hello ${name}!` `` — single-line, `${...}` interpolation. The ONLY escape is `\${` → literal `${`; every other backslash is literal (`` `\d+` `` stays `\d+`). A lone `$` not followed by `{` is literal. Interpolated values auto-stringify like `toString` (non-strings render as Dang literals, nested strings quoted; `null` → `"null"`).
68
-
- Multi-line: ```` ```...``` ```` — same minimum-indent dedent; fences grow (4+ backticks) to wrap shorter backtick blocks, and the close fence must match the open fence length. Optional language tag (` ```go ... ``` `) is parsed but does not affect the value.
64
+
### Strings
65
+
The delimiter decides how the contents are read; tripling it makes the string multi-line, dedented by minimum indent, with an optional language tag:
|`` ` ``| raw + `${...}`|```` ``` ````: raw + `${...}`|
72
+
73
+
Rule of thumb: **quotes are for text, backticks are for code; double quotes interpolate, single quotes don't.**
74
+
75
+
-**Double-quoted**`"hello, ${name}"` — escapes: `\a \b \f \n \r \t \v \" \\ \/ \$`, `\ooo` (octal), `\xNN`, `\uNNNN`, `\UNNNNNNNN`; `\/` yields `/`. Any other backslash is a syntax error (so a regex like `\d+` can't go in `"..."`). Interpolates `${...}`; only `${` starts one, never a bare `$name`. `\$` is a literal `$`, so `\${` is a literal `${`. Interpolated values auto-stringify like `toString` (non-strings render as Dang literals, nested strings quoted; `null` → `"null"`).
76
+
-**Single-quoted**`'${HOME}\bin'` — verbatim: no escapes, no interpolation. Can't hold a `'`: use `'''it's'''` (triple single quotes hold quotes, even inline) or `"it's"`. Use it for shell-ish text that must keep `${VAR}`: `.withEnvVariable("PATH", '${GOBIN}:${PATH}', expand: true)`; a shell script goes in `'''sh`.
77
+
-**Backtick templates**`` `\d+ ${x}` `` — raw text with `${...}` interpolation, for code (regexes, snippets). The ONLY escape is `\${` → literal `${`; every other backslash is literal (`` `\d+` `` stays `\d+`). A lone `$` not followed by `{` is literal. `#` inside is a literal character.
78
+
- Fences grow (4+ backticks) to wrap shorter backtick blocks; the close fence must match the open fence length.
79
+
-**Multi-line** (`"""`, `'''`, ```` ``` ````): the newline after the opening delimiter and the one before the closing delimiter are dropped (`"""\nhello\n"""` == `"hello"`), then the text is dedented by its minimum indent. A `"""` string is dedented **before** its escapes are decoded, so `\t` at the start of a line is text, not indentation, and an escape (`\x20`) keeps trailing whitespace. A `"` or `""` before the closing `"""` must be escaped.
80
+
-**Opening line**: holds at most a language tag (`"""sql`, `'''sh`, ```` ```go ````), which doesn't affect the value (editors highlight with it). Other text there is a syntax error (`text on the opening line of a multi-line string`) unless the string closes on the same line (`"""inline ${x}"""`). Careful: a lone word there IS a tag, so `"""Summary` + newline drops `Summary` from the value.
81
+
-**Docstrings** are triple-quoted but always verbatim (no escapes, no interpolation, no tag), and their text may start on the opening line.
82
+
-**Before Dang 2.5** (`dang = "2.4"` or older in dang.toml): `"..."` takes `${` literally and `"""` is raw (no escapes, interpolation or tag). `dang migrate` keeps every value: a `"..."` holding `${` becomes `'...'` where it can (else `\${`), a raw `"""` holding `\` or `${` becomes `'''` (else gets escapes), and text on an opening line moves to the next line.
83
+
- REPL output and `toString` of collections quote strings with `${` escaped (`["\${x}"]`), so they read back as the same value.
69
84
70
85
### Lists
71
86
-`[1, 2, 3]`, `["a", "b"]`, `[]` (empty), nested `[[1, 2], [3]]`. A trailing comma is fine, in list literals and call arguments alike (`[1, 2,]`, `f(a, b,)`).
@@ -104,7 +119,8 @@ greet(
104
119
### Gotchas
105
120
-**Untyped template bindings are `String!`**: `` let re = `\d+` `` is a String, not a `Regexp`; the literal-to-scalar coercion happens only where the literal meets a typed slot, so `s.containsMatch(re)` fails with `cannot use String! as Regexp!`. Annotate: `` let re: Regexp! = `\d+` `` (same for `Path!`, `URL!`, ...).
106
121
-**Write `!x`, not `x == false`**, on a `Boolean!`. `!` rejects a nullable `Boolean` (narrow it, or `!(x ?? false)`); `x == false` on one is `false` for null.
107
-
-**Prefer templates to `+` chains**: `` `${name} (${i})` `` over `name + " (" + toString(i) + ")"` — interpolation stringifies any value.
122
+
-**Prefer interpolation to `+` chains**: `"${name} (${i})"` over `name + " (" + toString(i) + ")"` — interpolation stringifies any value.
123
+
-**`${` in a `"..."` string interpolates**: shell variables, GitHub Actions expressions or `replaceMatches`' `${name}` backrefs belong in `'...'`/`'''...'''` (or escape them, `\${HOME}`). An unknown name is a compile error (`"HOME" not found; to write ${HOME} as text, single-quote the string or escape it as \${HOME}`), but a name that happens to be in scope interpolates silently.
108
124
109
125
### Arithmetic
110
126
-`+ - * / %` on `Int`/`Float` (mixed promotes to `Float`), or on a type variable bounded `[a: Numeric]` (see types.md). Float `%` is Go's `math.Mod`: the remainder takes the dividend's sign (`-7.5 % 2 == -1.5`).
0 commit comments