mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 12:56:33 +00:00
Miscellaneous book revisions
This commit is contained in:
parent
dccabdedef
commit
f4bf1626e1
3 changed files with 6 additions and 6 deletions
|
@ -1,12 +1,12 @@
|
|||
# Defining the parser: reporting errors
|
||||
|
||||
The last interesting case in the parser is how to handle a parse error.
|
||||
Because salsa functions are memoized and may not execute, they should not have side-effects,
|
||||
Because Salsa functions are memoized and may not execute, they should not have side-effects,
|
||||
so we don't just want to call `eprintln!`.
|
||||
If we did so, the error would only be reported the first time the function was called, but not
|
||||
on subsequent calls in the situation where the simply returns its memoized value.
|
||||
|
||||
salsa defines a mechanism for managing this called an **accumulator**.
|
||||
Salsa defines a mechanism for managing this called an **accumulator**.
|
||||
In our case, we define an accumulator struct called `Diagnostics` in the `ir` module:
|
||||
|
||||
```rust
|
||||
|
|
|
@ -63,7 +63,7 @@ It's generally better to structure tracked functions as functions of a single Sa
|
|||
|
||||
### The `return_ref` annotation
|
||||
|
||||
You may have noticed that `parse_statements` is tagged with `#[salsa::tracked(return_ref)]`. [The function isn't actually tagged with `return_ref`; is the text incorrect or the code example?]
|
||||
You may have noticed that `parse_statements` is tagged with `#[salsa::tracked(return_ref)]`.
|
||||
Ordinarily, when you call a tracked function, the result you get back is cloned out of the database.
|
||||
The `return_ref` attribute means that a reference into the database is returned instead.
|
||||
So, when called, `parse_statements` will return an `&Vec<Statement>` rather than cloning the `Vec`.
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# Videos
|
||||
|
||||
There are currently two videos about salsa available, but they describe an older version of salsa and so they are rather outdated:
|
||||
There are currently two videos about Salsa available, but they describe an older version of Salsa and so they are rather outdated:
|
||||
|
||||
- [How Salsa Works](https://youtu.be/_muY4HjSqVw), which gives a
|
||||
high-level introduction to the key concepts involved and shows how
|
||||
to use salsa;
|
||||
to use Salsa;
|
||||
- [Salsa In More Depth](https://www.youtube.com/watch?v=i_IhACacPRY),
|
||||
which digs into the incremental algorithm and explains -- at a
|
||||
high-level -- how salsa is implemented.
|
||||
high-level -- how Salsa is implemented.
|
||||
|
||||
> If you're in China, watch videos on [How Salsa Works](https://www.bilibili.com/video/BV1Df4y1A7t3/), [Salsa In More Depth](https://www.bilibili.com/video/BV1AM4y1G7E4/).
|
||||
|
|
Loading…
Reference in a new issue