notes:internals:db
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
notes:internals:db [2025/09/07 01:15] – smj-edison | notes:internals:db [2025/09/07 01:29] (current) – smj-edison | ||
---|---|---|---|
Line 4: | Line 4: | ||
and prelude.tcl.// | and prelude.tcl.// | ||
- | Folk's database stores all Wishes, Claims, Whens, and Holds. Essentially, | + | Folk's database stores all Wishes, Claims, |
- | in Folk. The database | + | in Folk. The data type of this database |
- | Wish, When, etc—are functions that insert a Statement into the database by calling the Say function. | + | Wish, Claim, and When. |
- | We'll cover Statement removal later. | + | |
===== Statements ===== | ===== Statements ===== | ||
So, what is a Statement? A Statement consists of two parts: the Clause and the child matches*. | So, what is a Statement? A Statement consists of two parts: the Clause and the child matches*. | ||
- | Let's start with the Clause: a Clause is an array of words, with each word known as a Term. An example | + | Let's start with the Clause: a Clause is an array of words, with each word known as a Term†. An example |
Clause, "the sky is blue", would become [" | Clause, "the sky is blue", would become [" | ||
- | === Wish and Claim === | + | === Wishes |
- | Let's see what happens when we run Wish. | + | Statements are inserted when running the core commands—Wish, |
+ | Say. Say inserts the provided Statement into the database. | ||
+ | |||
+ | Since Wish is a command that inserts a Statement, let's see what happens when we run it. | ||
< | < | ||
Line 57: | Line 59: | ||
Wait wait, what?? That was a lot all at once. Let's break it down. | Wait wait, what?? That was a lot all at once. Let's break it down. | ||
- | First, | + | First, the context. We just inserted a Statement, so we need to check if there' |
Whens that match. So, we do a database query. But what kind of query? Well, let's convert this Wish into | Whens that match. So, we do a database query. But what kind of query? Well, let's convert this Wish into | ||
what a When would look like for this Statement. The easiest way to explain this is to just look at a | what a When would look like for this Statement. The easiest way to explain this is to just look at a | ||
Line 80: | Line 82: | ||
as soon as a thread is available. | as soon as a thread is available. | ||
- | In fact, it's quite literally called | + | In fact, when this queued item runs, it is known as a Match. |
- | it creates | + | statements, which we'll get to in a bit. |
=== Statements and Matches === | === Statements and Matches === | ||
Line 157: | Line 159: | ||
=== Footnotes === | === Footnotes === | ||
- | * Also metadata, but this is already long enough. | + | * Also metadata |
+ | |||
+ | † This is a little misleading, as a Statement can have Terms with spaces in them. For example, | ||
+ | the last Term in `Wish $this has name "Mason Jones" | ||
+ | space seperated by default, and all the database commands are called from Tcl. |
notes/internals/db.txt · Last modified: 2025/09/07 01:29 by smj-edison