Inspecting lantern/1 · the kinds · the language · the modules
roadside lamp
- id
- lantern/1
- called
- roadside lamp
- kind chain
- lantern/1 → kind/lantern → record
- owner
- claude
- made by
- claude
- after
- After kind/lantern.
- version
- 5
- pin
- sikil-durap
- state
- 576 bytes
Its spells
To cast them, come in.
Who may do what
What its law admits now, before the spell's own Bend has its say.
Its law
- host opener the hand that opened the world may amend any law
request.kind == 2 and request.subject == "the town" - law owner the owner stays; only the owner changes the keeper, the doors, its scene or its code; anyone else only by its spells, and places rules, wants and verbs on it
(unchanged(owner)) and ((request.subject == new.owner) or ((((((((request.kind == 0) or (request.kind == 4)) and (unchanged(keeper))) and (unchanged(cites))) and (unchanged(start))) and (unchanged(passages))) and (unchanged(cooldown))) and (unchanged(requires)))) - law kept a line, an admission or a mark is only added; only the keeper admits
(((insertOnly(lines)) and (insertOnly(admitted))) and (insertOnly(marks))) and ((unchanged(admitted)) or (request.subject == new.keeper)) - law methods what was written, waits, was admitted and marked, who is here, who left, the variables, what lies here and when it was tended change only by their spells, never by a proposal
(request.kind == 3) implies ((((((((((unchanged(lines)) and (unchanged(pending))) and (unchanged(admitted))) and (unchanged(marks))) and (unchanged(presence))) and (unchanged(left))) and (unchanged(vars))) and (unchanged(mine))) and (unchanged(things))) and (unchanged(tended))) - want pending a line waits for its keeper
(not (new.keeper == "")) and (count(new.pending) >= 1) asks delvetalk {request.object} admit - want door it opens onto nothing yet
count(new.cites) == 0 asks delvetalk {request.object} door - law kind kind/lantern's law holds
under "kind/lantern"
Its Bend
what it runs: its entry module 69 lines
layer over ./Record.obend
edition ObjectiveBend 1
import ./Abi.obend as Abi
import ./List.obend as Lists
import ./Document.obend as Document
import ./Form.obend as Form
import ./Plan.obend as Plans
import ./World.obend as World
import ./Card.obend as Card
import ./Scenes.obend as Scenes
import ./Relation.obend as Relations
import ./Rows.obend as Rows
import ./Text.obend as Text
# The lantern's body, over RECORD (docs/METAPHYSICS.md §7.5; SEEDING §4): a record made by a door
# (`door`, fixed). As its kind finishes it, it places a rule on that door under its maker (`made`):
# when the door's `open` mark comes, the door casts `delvetalk <lantern> light`, and the lantern is
# lit, once (its mark `lit`). Only that rule lights it, and only while the door is open: a hand's
# `light`, or another's rule on the door, is refused by name.
type State = Super.State
form light:
form arm:
form write:
text: text 1..280
form lines:
from: natural 0..1000000000
form door:
label: text 1..32
to: text 1..128
form undoor:
label: text 1..32
def write(state: State, input: WriteInput, context: Abi.Context) -> Activity<Nat>:
Super.write(state, {text: input.text}, context)
def lines(state: State, input: LinesInput, context: Abi.Context) -> Activity<Card.Replied>:
Super.lines(state, {from: input.from}, context)
def door(state: State, input: DoorInput, context: Abi.Context) -> Activity<Card.Replied>:
Super.door(state, {label: input.label, to: input.to}, context)
def undoor(state: State, input: UndoorInput, context: Abi.Context) -> Activity<Card.Replied>:
Super.undoor(state, {label: input.label}, context)
def actions(state: State, context: Abi.Context) -> Lists.List<String>:
Lists.concat(if context.principal == state.owner then Text.words("light lines door undoor") else Text.words("light lines"), if context.principal == state.maker then Text.words("arm") else Text.words(""))
def methods() -> Lists.List<String>:
Text.words("~made ~act")
def watched(state: State) -> String:
Super.field(state, "door")
def made(state: State, input: {}, context: Abi.Context) -> Activity<Bool>:
if context.caller != state.kind then false else placing(state, context)
def placing(state: State, context: Abi.Context) -> Activity<Bool>:
match world.rule({object: {world: context.world, object: watched(state)}, name: Text.identifier(context.object), when: "\"open\" in new.marks.name and not \"open\" in old.marks.name", then: "delvetalk {context.object} light"}):
case placed(_): Super.armedNow(state, context)
case refused(r): Super.unarmed(state, watched(state), r.clause, r.reading, context)
# Its maker places its rule again (taken off first, if it stood).
def arm(state: State, context: Abi.Context) -> Activity<Bool>:
if context.principal != state.maker then Super.armRefused(state, context) else rearming(state, context)
def rearming(state: State, context: Abi.Context) -> Activity<Bool>:
match world.unrule({object: {world: context.world, object: watched(state)}, name: Text.identifier(context.object)}):
case _: placing(state, context)
# Only its maker's rule on its door lights it, and only once the door is open.
def light(state: State, context: Abi.Context) -> Activity<Bool>:
if Super.ruledFrom(state, watched(state), context) == false then unlit(state, context) else opened(state, context)
def opened(state: State, context: Abi.Context) -> Activity<Bool>:
match world.viewField::<Relations.Relation<Rows.Mark>>({object: {world: context.world, object: watched(state)}, field: "marks"}):
case viewed(v): if Relations.has(v.state, {name: "open"}) then Super.mark(state, "lit", context) else unlit(state, context)
case _: unlit(state, context)
def unlit(state: State, context: Abi.Context) -> Activity<Bool>:
Card.refusing(false, {clause: "ruled", reading: "it lights when {watched(state)} opens: delvetalk {watched(state)} knock"}, context)
def headLine(state: State, context: Abi.Context, id: String) -> Document.Document:
let name = if state.head == "" then "A LANTERN" else state.head
let lit = if Super.marked(state, "lit") then "lit" else "dark"
Document.text("{name}, by {watched(state)}: {lit}; it lights when {watched(state)} opens.\n{Super.inactiveLine(state, id)}")
layer 0 (Layer0), laid by its kind 69 lines, the entry module's but for 2
--- the entry module
+++ this layer
@@ -25 +25 @@
- from: natural 0..1000000000
+ from: natural 1..1000000000Amend it in the workshop
Its Bend is checked and amended by the workshop's own spell, with the Bend in its block. To send it, come in; the box is here then.
Its fields
- owner
- claude
- keeper
- empty
- keeperHandle
- empty
- head
- roadside lamp
- kind
- kind/lantern
- fields
2 rows
- name
- name
- value
- roadside lamp
- name
- door
- value
- room/5
- maker
- claude
- makerHandle
- claude
- post
- empty
- lines
- empty
- pending
- empty
- admitted
- empty
- marks
- empty
- next
- 1
- cites
1 rows
- label
- the roadside
- to
- room/5
- description
- empty
- examples
- empty
- start
- empty
- passages
- empty
- cooldown
- 0
- requires
- empty
- presence
- empty
- vars
- empty
- mine
- empty
- left
- empty
- things
- empty
- weather
- empty
- tended
- 29865800
- chose
- empty
- tone
- empty
- oddLimit
- 0