Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ The `--watch` / `-w` flag works with `run`, `check`, `disasm`, and `test` to re-

`silt check` reports what is wrong with the whole file: a declaration that does not parse is one error, and the declarations behind it are read and checked all the same, as is the text behind a character that belongs to no token. At most fifty syntax errors of a file are shown, with a count of the rest. A file that ends inside a string or a `{- -}` comment that is not closed reports that and nothing else. A file with a syntax error is never run or formatted.

`silt repl` checks each input as `silt check` checks a file, and runs it. It sees the directory it was started in as a script does: `import shapes` loads `shapes.silt` beside it, or `src/shapes.silt` and the dependencies of the package there. An input sees what the inputs before it define; an input with an error is dropped and changes nothing. Defining a function or a `let` again makes a new definition for the inputs after it: code from earlier inputs keeps the definition it was written against. Errors are shown at `<repl:n>:line:col`, the `n`th input. A module is read the first time an input imports it and kept for the session: edits to its file are seen after a restart. In a package, the REPL updates `silt.lock` as `silt run` does.
`silt repl` checks each input as `silt check` checks a file, and runs it. It sees the directory it was started in as a script does: `import shapes` loads `shapes.silt` beside it, or `src/shapes.silt` and the dependencies of the package there. An input sees what the inputs before it define; an input with an error is dropped and changes nothing. Defining a function or a `let` again makes a new definition for the inputs after it: code from earlier inputs keeps the definition it was written against. Errors are shown at `<repl:n>:line:col`, the `n`th input. A module is read the first time an input imports it and kept for the session: edits to its file are seen after a restart. In a package, the REPL updates `silt.lock` as `silt run` does. `:type <expr>` shows the type of an expression without running it (`:type Some` is `Fn(a) -> Option(a)`; its expression is checked as an input, and counts as one), and `:doc <name>` what a builtin is: a function's signature, the declaration of a type, a trait or a variant's enum, with what its docs say first, or all a module declares (`:doc list.map`, `:doc Option`, `:doc string`); `:help` lists the commands.

### Staying up to date

Expand Down
11 changes: 7 additions & 4 deletions docs/stdlib/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ No import or qualification needed.
|------|-----------|-------------|
| `print` | `(a) -> () where a: Display` | Print a value without trailing newline |
| `println` | `(a) -> () where a: Display` | Print a value with trailing newline |
| `panic` | `(a) -> b where a: Display` | Crash with an error message |
| `panic` | `(a) -> Never where a: Display` | Crash with an error message |
| `Ok` | `(a) -> Result(a, e)` | Construct a success Result |
| `Err` | `(e) -> Result(a, e)` | Construct an error Result |
| `Some` | `(a) -> Option(a)` | Construct a present Option |
Expand Down Expand Up @@ -108,12 +108,15 @@ fn main() {
## `panic`

```
panic(value: a) -> b where a: Display
panic(message: a) -> Never where a: Display
```

Terminates execution with an error message. Accepts any value that implements
`Display`. The return type is polymorphic because `panic` never returns -- it
can appear anywhere a value is expected.
`Display`. It never returns: its result is of type `Never`, the type of an expression
that does not return (`return`, `loop(...)`), which goes with every type, so
`panic` can stand wherever a value is expected and ends an `else` block that
must leave. `Never` is not written in an annotation (see [the Never
type](../language/error-handling.md#never-type)).

```silt
-- noexec
Expand Down
Loading
Loading