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 version https://git-lfs.github.com/spec/v1
oid sha256:48eb6f561c22b0bd4828bd1f1690fb4f54fc9c092a6c2f48f2a995af53188d02 oid sha256:89e9469aa6e5d9da7cfb62aeed0424c7f2ba0364b8fb7a84b1366219406038d0
size 16851284 size 16997852

View File

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

View File

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

View File

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