Recommend runDataspace, not bootDataspace
This commit is contained in:
parent
8bb9fb16d7
commit
219286a84a
|
@ -49,12 +49,12 @@ assert present.fromPreserve(pr) == true
|
||||||
|
|
||||||
## The Syndicate DSL
|
## The Syndicate DSL
|
||||||
|
|
||||||
The Syndicate DSL can be entered using `bootDataspace` which calls a Nim body with a [dataspace](https://synit.org/book/glossary.html#dataspace) [Ref](https://synit.org/book/glossary.html#reference) and a [turn](https://synit.org/book/glossary.html#turn). The `Ref` is something that we can observe and publish assertions at, and a `Turn` is special type for temporal scoping and transactional semantics. Assertions can be published using the `Assertion` or equivalent `Preserve[Ref]` type, but using Nim types is preferred because they can be reliably consistent with schema.
|
The Syndicate DSL can be entered using `runActor` which calls a Nim body with a [dataspace](https://synit.org/book/glossary.html#dataspace) [Ref](https://synit.org/book/glossary.html#reference) and a [turn](https://synit.org/book/glossary.html#turn). The `Ref` is something that we can observe and publish assertions at, and a `Turn` is special type for temporal scoping and transactional semantics. Assertions can be published using the `Assertion` or equivalent `Preserve[Ref]` type, but using Nim types is preferred because they can be reliably consistent with schema.
|
||||||
|
|
||||||
### Publish
|
### Publish
|
||||||
|
|
||||||
``` nim
|
``` nim
|
||||||
bootDataspace("main") do (dataspace: Ref; turn: var Turn):
|
runActor("main") do (dataspace: Ref; turn: var Turn):
|
||||||
let presenceHandle = publish(turn, dataspace, Present(username: "Judy"))
|
let presenceHandle = publish(turn, dataspace, Present(username: "Judy"))
|
||||||
# publish <Present "Judy"> to the dataspace
|
# publish <Present "Judy"> to the dataspace
|
||||||
# the assertion can be later retracted by handle
|
# the assertion can be later retracted by handle
|
||||||
|
@ -67,7 +67,7 @@ bootDataspace("main") do (dataspace: Ref; turn: var Turn):
|
||||||
We can react to assertions and messages within dataspaces using [patterns](https://synit.org/book/glossary.html#dataspace-pattern). Patterns are constructed using a Nim type and the `?` operator. Again a Nim type is used rather than a raw Preserves for schema consistency.
|
We can react to assertions and messages within dataspaces using [patterns](https://synit.org/book/glossary.html#dataspace-pattern). Patterns are constructed using a Nim type and the `?` operator. Again a Nim type is used rather than a raw Preserves for schema consistency.
|
||||||
|
|
||||||
``` nim
|
``` nim
|
||||||
bootDataspace("main") do (dataspace: Ref; turn: var Turn):
|
runActor("main") do (dataspace: Ref; turn: var Turn):
|
||||||
during(turn, dataspace, ?Present) do (who: string):
|
during(turn, dataspace, ?Present) do (who: string):
|
||||||
# This body is active when the ?Present pattern is matched.
|
# This body is active when the ?Present pattern is matched.
|
||||||
# The Present type contains two atomic values that can be matched
|
# The Present type contains two atomic values that can be matched
|
||||||
|
|
|
@ -41,7 +41,7 @@ proc newDataspace*(turn: var Turn): Ref =
|
||||||
|
|
||||||
type BootProc = proc (ds: Ref; turn: var Turn) {.gcsafe.}
|
type BootProc = proc (ds: Ref; turn: var Turn) {.gcsafe.}
|
||||||
|
|
||||||
proc bootDataspace*(name: string; bootProc: BootProc): Actor {.discardable.} =
|
proc bootDataspace*(name: string; bootProc: BootProc): Actor =
|
||||||
bootActor(name) do (turn: var Turn):
|
bootActor(name) do (turn: var Turn):
|
||||||
discard turn.facet.preventInertCheck()
|
discard turn.facet.preventInertCheck()
|
||||||
bootProc(newDataspace(turn), turn)
|
bootProc(newDataspace(turn), turn)
|
||||||
|
|
|
@ -53,8 +53,8 @@ type
|
||||||
|
|
||||||
|
|
||||||
SturdyDescriptionDetail*[Cap] {.preservesDictionary.} = object
|
SturdyDescriptionDetail*[Cap] {.preservesDictionary.} = object
|
||||||
`oid`*: Preserve[Cap]
|
|
||||||
`key`*: seq[byte]
|
`key`*: seq[byte]
|
||||||
|
`oid`*: Preserve[Cap]
|
||||||
|
|
||||||
PAnd*[Cap] {.preservesRecord: "and".} = ref object
|
PAnd*[Cap] {.preservesRecord: "and".} = ref object
|
||||||
`patterns`*: seq[Pattern[Cap]]
|
`patterns`*: seq[Pattern[Cap]]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "20230611"
|
version = "20230630"
|
||||||
author = "Emery Hemingway"
|
author = "Emery Hemingway"
|
||||||
description = "Syndicated actors for conversational concurrency"
|
description = "Syndicated actors for conversational concurrency"
|
||||||
license = "Unlicense"
|
license = "Unlicense"
|
||||||
|
|
Loading…
Reference in New Issue