mall: use +stay instead of explicit state

This commit is contained in:
Philip Monk 2019-09-04 14:20:47 -07:00
parent bc1ba10a11
commit f52e60bb09
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
4 changed files with 82 additions and 76 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:48eb6f561c22b0bd4828bd1f1690fb4f54fc9c092a6c2f48f2a995af53188d02
size 16851284
oid sha256:89e9469aa6e5d9da7cfb62aeed0424c7f2ba0364b8fb7a84b1366219406038d0
size 16997852

View File

@ -1,45 +1,50 @@
/+ agent
|%
+$ in-poke-data %hoy
++ agent (^agent ,~ in-poke-data ,*)
--
%- agent-to-mall-agent:agent
^- agent:agent
|_ [bowl:mall state=~]
^- agent:mall
=| state=@
|_ bowl:mall
++ handle-init
`~
`..handle-init
::
++ handle-prep
|~ old-state=vase
*step:agent:agent
|= =old-state=vase
=/ old-state !<(@ old-state-vase)
?~ old-state
~& %prep-lost
`..handle-init
~& %prep-found
`..handle-init(state u.old-state)
::
++ handle-poke
|= =a=in-poke-data
~& >> 'ouchers!'
~& >>> a-in-poke-data
*step:agent:agent
|= in-poke-data=cage
~& >> 'ouchies!'
~& >>> in-poke-data
~& > state=state
=. state +(state)
`..handle-init
::
++ handle-peer
|~ path
*step:agent:agent
|= path
`..handle-init
::
++ handle-pull
|~ path
*step:agent:agent
|= path
`..handle-init
::
++ handle-peek
|~ path
|= path
*(unit (unit cage))
::
++ handle-mall
|~ [wire internal-gift:mall]
*step:agent:agent
|= [wire internal-gift:mall]
`..handle-init
::
++ handle-take
|~ [wire *]
*step:agent:agent
|= [wire vase]
`..handle-init
::
++ handle-lame
|~ [term tang]
*step:agent:agent
|= [term tang]
`..handle-init
::
++ handle-stay
!>(state)
--

View File

@ -156,9 +156,6 @@
:: agent core
::
=agent
:: running state
::
state=vase
:: update control
::
=beak
@ -348,7 +345,6 @@
control-duct hen
beak beak
agent agent
state !>(~)
ducts ducts
==
::
@ -1090,7 +1086,7 @@
:: +ap-agent-core: agent core with current bowl and state
::
++ ap-agent-core
~(. agent.current-agent ap-construct-bowl state.current-agent)
~(. agent.current-agent ap-construct-bowl)
:: +ap-apply: apply effect.
::
++ ap-apply
@ -1244,8 +1240,8 @@
::
=/ prep
=/ =agent u.maybe-agent
=/ running (some ~(handle-stay agent.current-agent ap-construct-bowl))
=/ installed ap-install(agent.current-agent agent)
=/ running (some state.current-agent)
(installed running)
::
=^ maybe-tang ap-core prep
@ -1440,7 +1436,7 @@
::
:- (flop -.p.result)
%_ ap-core
state.current-agent +.p.result
agent.current-agent +.p.result
incoming.subscribers.current-agent new-subs
==
:: +ap-handle-quits: handle cancels of incoming subscriptions
@ -1571,7 +1567,7 @@
^+ mall-payload
::
?- -.state-old
%0 mall-payload :: (state state-old)
%0 mall-payload(state state-old)
==
:: +scry: standard scry
::

View File

@ -1941,46 +1941,51 @@
:: +agent: app core
::
++ agent
=> |%
+$ move internal-move
+$ step (quip move new-state=vase)
--
$_ ^|
|_ [bowl state=vase]
++ handle-init
*step
::
++ handle-prep
|~ old-state=vase
*step
::
++ handle-poke
|~ in-poke-data=cage
*step
::
++ handle-peer
|~ path
*step
::
++ handle-pull
|~ path
*step
::
++ handle-peek
|~ path
*(unit (unit cage))
::
++ handle-mall
|~ [wire internal-gift]
*step
::
++ handle-take
|~ [wire sign=vase]
*step
::
++ handle-lame
|~ [term tang]
*step
=< form
|%
+$ move internal-move
+$ step (quip move form)
++ form
$_ ^|
|_ bowl
++ handle-init
*(quip move _^|(..handle-init))
::
++ handle-prep
|~ old-state=vase
*(quip move _^|(..handle-init))
::
++ handle-poke
|~ in-poke-data=cage
*(quip move _^|(..handle-init))
::
++ handle-peer
|~ path
*(quip move _^|(..handle-init))
::
++ handle-pull
|~ path
*(quip move _^|(..handle-init))
::
++ handle-peek
|~ path
*(unit (unit cage))
::
++ handle-mall
|~ [wire internal-gift]
*(quip move _^|(..handle-init))
::
++ handle-take
|~ [wire sign=vase]
*(quip move _^|(..handle-init))
::
++ handle-lame
|~ [term tang]
*(quip move _^|(..handle-init))
::
++ handle-stay
*vase
--
--
-- ::mall
:: ::::