mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-07 07:30:23 +03:00
Merge branch 'test' of github.com:urbit/urbit-new into test
This commit is contained in:
commit
c09899136e
250
arvo/hoon.hoon
250
arvo/hoon.hoon
@ -74,6 +74,7 @@
|
|||||||
== ::
|
== ::
|
||||||
++ gate $+(* *) :: general gate
|
++ gate $+(* *) :: general gate
|
||||||
++ hair ,[p=@ud q=@ud] :: parsing trace
|
++ hair ,[p=@ud q=@ud] :: parsing trace
|
||||||
|
++ hapt (list ,@ta) :: XX not used
|
||||||
++ like |* a=_,* :: generic edge
|
++ like |* a=_,* :: generic edge
|
||||||
|= b=_`*`[(hair) ~] ::
|
|= b=_`*`[(hair) ~] ::
|
||||||
:- p=(hair -.b) ::
|
:- p=(hair -.b) ::
|
||||||
@ -127,6 +128,7 @@
|
|||||||
== ::
|
== ::
|
||||||
++ qual |* [a=$+(* *) b=$+(* *) c=$+(* *) d=$+(* *)] :: just a quadruple
|
++ qual |* [a=$+(* *) b=$+(* *) c=$+(* *) d=$+(* *)] :: just a quadruple
|
||||||
,[p=a q=b r=c s=d] ::
|
,[p=a q=b r=c s=d] ::
|
||||||
|
:: XX move to zuse
|
||||||
++ rege $| ?(%dote %ende %sart %empt %boun %bout) :: parsed regex
|
++ rege $| ?(%dote %ende %sart %empt %boun %bout) :: parsed regex
|
||||||
$% [%lite p=char] :: literal
|
$% [%lite p=char] :: literal
|
||||||
[%pair p=rege q=rege] :: ordering
|
[%pair p=rege q=rege] :: ordering
|
||||||
@ -157,7 +159,7 @@
|
|||||||
p=[p=tape q=tape r=tape] ::
|
p=[p=tape q=tape r=tape] ::
|
||||||
q=(list tank) ::
|
q=(list tank) ::
|
||||||
== ::
|
== ::
|
||||||
== ::
|
==
|
||||||
++ tape (list char) :: like a string
|
++ tape (list char) :: like a string
|
||||||
++ term ,@tas :: Hoon ASCII subset
|
++ term ,@tas :: Hoon ASCII subset
|
||||||
++ tiki :: test case
|
++ tiki :: test case
|
||||||
@ -202,10 +204,10 @@
|
|||||||
[%bctr p=tile] :: static bunt w/ ^~
|
[%bctr p=tile] :: static bunt w/ ^~
|
||||||
[%bczp p=base] :: bunt an axil
|
[%bczp p=base] :: bunt an axil
|
||||||
:: :::::: cores
|
:: :::::: cores
|
||||||
[%brcb p=tile q=(map term foot)] :: %gold door, sample p
|
[%brcb p=tile q=(map term foot)] :: %gold tray, sample p
|
||||||
[%brcn p=(map term foot)] :: %gold core, natural
|
[%brcn p=(map term foot)] :: %gold core, natural
|
||||||
[%brdt p=twig] :: dry %gold trap
|
[%brdt p=twig] :: dry %gold trap
|
||||||
[%brfs p=tile q=(map term foot)] :: vulcan. %gold door
|
[%brfs p=tile q=(map term foot)] :: vulcan. %gold tray
|
||||||
[%brkt p=twig q=(map term foot)] :: %gold book
|
[%brkt p=twig q=(map term foot)] :: %gold book
|
||||||
[%brhp p=twig] :: kick dry %gold trap
|
[%brhp p=twig] :: kick dry %gold trap
|
||||||
[%brls p=tile q=twig] :: dry %iron gate
|
[%brls p=tile q=twig] :: dry %iron gate
|
||||||
@ -222,6 +224,7 @@
|
|||||||
[%clls p=twig q=twig r=twig] :: [p q r]
|
[%clls p=twig q=twig r=twig] :: [p q r]
|
||||||
[%clsg p=tusk] :: [p ~]
|
[%clsg p=tusk] :: [p ~]
|
||||||
[%cltr p=tusk] :: p as a tuple
|
[%cltr p=tusk] :: p as a tuple
|
||||||
|
[%clzz p=tusk] :: macro
|
||||||
:: :::::: invocations
|
:: :::::: invocations
|
||||||
[%cncb p=wing q=tram] :: %=, then cast to p
|
[%cncb p=wing q=tram] :: %=, then cast to p
|
||||||
[%cncl p=twig q=twig] :: pull $.p w/ sample q
|
[%cncl p=twig q=twig] :: pull $.p w/ sample q
|
||||||
@ -400,7 +403,7 @@
|
|||||||
++ vise ,[p=typo q=*] :: old vase
|
++ vise ,[p=typo q=*] :: old vase
|
||||||
++ wall (list tape) :: text lines (no \n)
|
++ wall (list tape) :: text lines (no \n)
|
||||||
++ wain (list cord) :: text lines (no \n)
|
++ wain (list cord) :: text lines (no \n)
|
||||||
++ wing (list limb) :: namespace address
|
++ wing (list limb) ::
|
||||||
++ wine $| ?(%noun %path %tank %void %wall %wool %yarn)
|
++ wine $| ?(%noun %path %tank %void %wall %wool %yarn)
|
||||||
$% [%atom p=term] ::
|
$% [%atom p=term] ::
|
||||||
[%core p=(list ,@ta) q=wine] ::
|
[%core p=(list ,@ta) q=wine] ::
|
||||||
@ -446,8 +449,7 @@
|
|||||||
~/ %add
|
~/ %add
|
||||||
|= [a=@ b=@]
|
|= [a=@ b=@]
|
||||||
^- @
|
^- @
|
||||||
?: =(0 a)
|
?: =(0 a) b
|
||||||
b
|
|
||||||
$(a (dec a), b +(b))
|
$(a (dec a), b +(b))
|
||||||
::
|
::
|
||||||
++ cap :: tree head
|
++ cap :: tree head
|
||||||
@ -468,8 +470,7 @@
|
|||||||
?< =(0 a)
|
?< =(0 a)
|
||||||
=+ b=0
|
=+ b=0
|
||||||
|- ^- @
|
|- ^- @
|
||||||
?: =(a +(b))
|
?: =(a +(b)) b
|
||||||
b
|
|
||||||
$(b +(b))
|
$(b +(b))
|
||||||
::
|
::
|
||||||
++ div :: divide
|
++ div :: divide
|
||||||
@ -480,16 +481,14 @@
|
|||||||
?< =(0 b)
|
?< =(0 b)
|
||||||
=+ c=0
|
=+ c=0
|
||||||
|-
|
|-
|
||||||
?: (lth a b)
|
?: (lth a b) c
|
||||||
c
|
|
||||||
$(a (sub a b), c +(c))
|
$(a (sub a b), c +(c))
|
||||||
::
|
::
|
||||||
++ fac :: factorial
|
++ fac :: factorial
|
||||||
~/ %fac
|
~/ %fac
|
||||||
|= a=@
|
|= a=@
|
||||||
^- @
|
^- @
|
||||||
?: =(0 a)
|
?: =(0 a) 1
|
||||||
1
|
|
||||||
(mul a $(a (dec a)))
|
(mul a $(a (dec a)))
|
||||||
::
|
::
|
||||||
++ gte :: greater-equal
|
++ gte :: greater-equal
|
||||||
@ -535,16 +534,14 @@
|
|||||||
~/ %max
|
~/ %max
|
||||||
|= [a=@ b=@]
|
|= [a=@ b=@]
|
||||||
^- @
|
^- @
|
||||||
?: (gth a b)
|
?: (gth a b) a
|
||||||
a
|
|
||||||
b
|
b
|
||||||
::
|
::
|
||||||
++ min :: minimum
|
++ min :: minimum
|
||||||
~/ %min
|
~/ %min
|
||||||
|= [a=@ b=@]
|
|= [a=@ b=@]
|
||||||
^- @
|
^- @
|
||||||
?: (lth a b)
|
?: (lth a b) a
|
||||||
a
|
|
||||||
b
|
b
|
||||||
::
|
::
|
||||||
++ mod :: remainder
|
++ mod :: remainder
|
||||||
@ -560,8 +557,7 @@
|
|||||||
^- @
|
^- @
|
||||||
=+ c=0
|
=+ c=0
|
||||||
|-
|
|-
|
||||||
?: =(0 a)
|
?: =(0 a) c
|
||||||
c
|
|
||||||
$(a (dec a), c (add b c))
|
$(a (dec a), c (add b c))
|
||||||
::
|
::
|
||||||
++ peg :: tree connect
|
++ peg :: tree connect
|
||||||
@ -580,8 +576,7 @@
|
|||||||
|= [a=@ b=@]
|
|= [a=@ b=@]
|
||||||
~| %subtract-underflow
|
~| %subtract-underflow
|
||||||
^- @
|
^- @
|
||||||
?: =(0 b)
|
?: =(0 b) a
|
||||||
a
|
|
||||||
$(a (dec a), b (dec b))
|
$(a (dec a), b (dec b))
|
||||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::: ::
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::: ::
|
||||||
:::: chapter 2b, basic containers ::::
|
:::: chapter 2b, basic containers ::::
|
||||||
@ -590,14 +585,12 @@
|
|||||||
::
|
::
|
||||||
++ biff :: apply
|
++ biff :: apply
|
||||||
|* [a=(unit) b=$+(* (unit))]
|
|* [a=(unit) b=$+(* (unit))]
|
||||||
?~ a
|
?~ a ~
|
||||||
~
|
|
||||||
(b u.a)
|
(b u.a)
|
||||||
::
|
::
|
||||||
++ bind :: argue
|
++ bind :: argue
|
||||||
|* [a=(unit) b=gate]
|
|* [a=(unit) b=gate]
|
||||||
?~ a
|
?~ a ~
|
||||||
~
|
|
||||||
[~ u=(b u.a)]
|
[~ u=(b u.a)]
|
||||||
::
|
::
|
||||||
++ bond :: replace
|
++ bond :: replace
|
||||||
@ -614,16 +607,13 @@
|
|||||||
::
|
::
|
||||||
++ clap :: combine
|
++ clap :: combine
|
||||||
|* [a=(unit) b=(unit) c=_|=(^ +<-)]
|
|* [a=(unit) b=(unit) c=_|=(^ +<-)]
|
||||||
?~ a
|
?~ a b
|
||||||
b
|
?~ b a
|
||||||
?~ b
|
|
||||||
a
|
|
||||||
[~ u=(c u.a u.b)]
|
[~ u=(c u.a u.b)]
|
||||||
::
|
::
|
||||||
++ drop :: enlist
|
++ drop :: enlist
|
||||||
|* a=(unit)
|
|* a=(unit)
|
||||||
?~ a
|
?~ a ~
|
||||||
~
|
|
||||||
[i=u.a t=~]
|
[i=u.a t=~]
|
||||||
::
|
::
|
||||||
++ fall :: default
|
++ fall :: default
|
||||||
@ -637,16 +627,13 @@
|
|||||||
::
|
::
|
||||||
++ mate :: choose
|
++ mate :: choose
|
||||||
|* [a=(unit) b=(unit)]
|
|* [a=(unit) b=(unit)]
|
||||||
?~ b
|
?~ b a
|
||||||
a
|
?~ a b
|
||||||
?~ a
|
|
||||||
b
|
|
||||||
?.(=(u.a u.b) ~|('mate' !!) a)
|
?.(=(u.a u.b) ~|('mate' !!) a)
|
||||||
::
|
::
|
||||||
++ need :: demand
|
++ need :: demand
|
||||||
|* a=(unit)
|
|* a=(unit)
|
||||||
?~ a
|
?~ a !!
|
||||||
!!
|
|
||||||
u.a
|
u.a
|
||||||
::
|
::
|
||||||
++ some :: lift (pure)
|
++ some :: lift (pure)
|
||||||
@ -662,8 +649,7 @@
|
|||||||
^+ a
|
^+ a
|
||||||
=+ b=`_a`~
|
=+ b=`_a`~
|
||||||
|-
|
|-
|
||||||
?~ a
|
?~ a b
|
||||||
b
|
|
||||||
$(a t.a, b [i.a b])
|
$(a t.a, b [i.a b])
|
||||||
::
|
::
|
||||||
++ homo :: homogenize
|
++ homo :: homogenize
|
||||||
@ -686,17 +672,16 @@
|
|||||||
^- @
|
^- @
|
||||||
=+ b=0
|
=+ b=0
|
||||||
|-
|
|-
|
||||||
?~(a b $(a t.a, b +(b)))
|
?~ a b
|
||||||
|
$(a t.a, b +(b))
|
||||||
::
|
::
|
||||||
++ levy
|
++ levy
|
||||||
~/ %levy :: all of
|
~/ %levy :: all of
|
||||||
|* [a=(list) b=_|=(p=* .?(p))]
|
|* [a=(list) b=_|=(p=* .?(p))]
|
||||||
|- ^- ?
|
|- ^- ?
|
||||||
?~ a
|
?~ a &
|
||||||
&
|
?. (b i.a) |
|
||||||
?: (b i.a)
|
|
||||||
$(a t.a)
|
$(a t.a)
|
||||||
|
|
|
||||||
::
|
::
|
||||||
++ lien :: some of
|
++ lien :: some of
|
||||||
~/ %lien
|
~/ %lien
|
||||||
@ -709,8 +694,7 @@
|
|||||||
++ murn :: maybe transform
|
++ murn :: maybe transform
|
||||||
|* [a=(list) b=$+(* (unit))]
|
|* [a=(list) b=$+(* (unit))]
|
||||||
|-
|
|-
|
||||||
?~ a
|
?~ a ~
|
||||||
~
|
|
||||||
=+ c=(b i.a)
|
=+ c=(b i.a)
|
||||||
?~ c
|
?~ c
|
||||||
$(a t.a)
|
$(a t.a)
|
||||||
@ -720,8 +704,7 @@
|
|||||||
|* [a=@ b=*]
|
|* [a=@ b=*]
|
||||||
=| c=(list)
|
=| c=(list)
|
||||||
|- ^- (list)
|
|- ^- (list)
|
||||||
?: =(a 0)
|
?: =(a 0) c
|
||||||
c
|
|
||||||
$(c [b c], a (dec a))
|
$(c [b c], a (dec a))
|
||||||
::
|
::
|
||||||
++ reel :: right fold
|
++ reel :: right fold
|
||||||
@ -745,25 +728,23 @@
|
|||||||
|- ^+ [p=a q=a]
|
|- ^+ [p=a q=a]
|
||||||
?~ a [~ ~]
|
?~ a [~ ~]
|
||||||
=+ c=$(a t.a)
|
=+ c=$(a t.a)
|
||||||
?: (b i.a)
|
?:((b i.a) [[i.a p.c] q.c] [p.c [i.a q.c]])
|
||||||
[[i.a p.c] q.c]
|
|
||||||
[p.c [i.a q.c]]
|
|
||||||
::
|
::
|
||||||
++ skim :: only
|
++ skim :: only
|
||||||
~/ %skim
|
~/ %skim
|
||||||
|* [a=(list) b=_|=(p=* .?(p))]
|
|* [a=(list) b=_|=(p=* .?(p))]
|
||||||
|- ^+ a
|
|-
|
||||||
|
^+ a
|
||||||
?~ a ~
|
?~ a ~
|
||||||
?. (b i.a) $(a t.a)
|
?:((b i.a) [i.a $(a t.a)] $(a t.a))
|
||||||
[i.a $(a t.a)]
|
|
||||||
::
|
::
|
||||||
++ skip :: except
|
++ skip :: except
|
||||||
~/ %skip
|
~/ %skip
|
||||||
|* [a=(list) b=_|=(p=* .?(p))]
|
|* [a=(list) b=_|=(p=* .?(p))]
|
||||||
|- ^+ a
|
|-
|
||||||
|
^+ a
|
||||||
?~ a ~
|
?~ a ~
|
||||||
?: (b i.a) $(a t.a)
|
?:((b i.a) $(a t.a) [i.a $(a t.a)])
|
||||||
[i.a $(a t.a)]
|
|
||||||
::
|
::
|
||||||
++ scag :: prefix
|
++ scag :: prefix
|
||||||
~/ %scag
|
~/ %scag
|
||||||
@ -784,7 +765,8 @@
|
|||||||
~/ %snag
|
~/ %snag
|
||||||
|* [a=@ b=(list)]
|
|* [a=@ b=(list)]
|
||||||
|-
|
|-
|
||||||
?~ b ~|('snag-fail' !!)
|
?~ b
|
||||||
|
~|('snag-fail' !!)
|
||||||
?: =(0 a) i.b
|
?: =(0 a) i.b
|
||||||
$(b t.b, a (dec a))
|
$(b t.b, a (dec a))
|
||||||
::
|
::
|
||||||
@ -851,8 +833,7 @@
|
|||||||
~/ %bex
|
~/ %bex
|
||||||
|= a=@
|
|= a=@
|
||||||
^- @
|
^- @
|
||||||
?: =(0 a)
|
?: =(0 a) 1
|
||||||
1
|
|
||||||
(mul 2 $(a (dec a)))
|
(mul 2 $(a (dec a)))
|
||||||
::
|
::
|
||||||
++ xeb :: binary logarithm
|
++ xeb :: binary logarithm
|
||||||
@ -910,8 +891,7 @@
|
|||||||
~/ %rap
|
~/ %rap
|
||||||
|= [a=bloq b=(list ,@)]
|
|= [a=bloq b=(list ,@)]
|
||||||
^- @
|
^- @
|
||||||
?~ b
|
?~ b 0
|
||||||
0
|
|
||||||
(cat a i.b $(b t.b))
|
(cat a i.b $(b t.b))
|
||||||
::
|
::
|
||||||
++ rep :: assemble single
|
++ rep :: assemble single
|
||||||
@ -920,16 +900,14 @@
|
|||||||
^- @
|
^- @
|
||||||
=+ c=0
|
=+ c=0
|
||||||
|-
|
|-
|
||||||
?~ b
|
?~ b 0
|
||||||
0
|
|
||||||
(con (lsh a c (end a 1 i.b)) $(c +(c), b t.b))
|
(con (lsh a c (end a 1 i.b)) $(c +(c), b t.b))
|
||||||
::
|
::
|
||||||
++ rip :: disassemble
|
++ rip :: disassemble
|
||||||
~/ %rip
|
~/ %rip
|
||||||
|= [a=bloq b=@]
|
|= [a=bloq b=@]
|
||||||
^- (list ,@)
|
^- (list ,@)
|
||||||
?: =(0 b)
|
?: =(0 b) ~
|
||||||
~
|
|
||||||
[(end a 1 b) $(b (rsh a 1 b))]
|
[(end a 1 b) $(b (rsh a 1 b))]
|
||||||
::
|
::
|
||||||
++ rsh :: right-shift
|
++ rsh :: right-shift
|
||||||
@ -947,13 +925,16 @@
|
|||||||
|= [a=@ b=@]
|
|= [a=@ b=@]
|
||||||
=+ [c=0 d=0]
|
=+ [c=0 d=0]
|
||||||
|- ^- @
|
|- ^- @
|
||||||
?: ?&(=(0 a) =(0 b))
|
?: ?&(=(0 a) =(0 b)) d
|
||||||
d
|
|
||||||
%= $
|
%= $
|
||||||
a (rsh 0 1 a)
|
a (rsh 0 1 a)
|
||||||
b (rsh 0 1 b)
|
b (rsh 0 1 b)
|
||||||
c +(c)
|
c +(c)
|
||||||
d (add d (lsh 0 c ?&(=(0 (end 0 1 a)) =(0 (end 0 1 b)))))
|
d %+ add d
|
||||||
|
%^ lsh 0 c
|
||||||
|
?& =(0 (end 0 1 a))
|
||||||
|
=(0 (end 0 1 b))
|
||||||
|
==
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ dis :: binary and
|
++ dis :: binary and
|
||||||
@ -961,13 +942,16 @@
|
|||||||
|= [a=@ b=@]
|
|= [a=@ b=@]
|
||||||
=| [c=@ d=@]
|
=| [c=@ d=@]
|
||||||
|- ^- @
|
|- ^- @
|
||||||
?: ?|(=(0 a) =(0 b))
|
?: ?|(=(0 a) =(0 b)) d
|
||||||
d
|
|
||||||
%= $
|
%= $
|
||||||
a (rsh 0 1 a)
|
a (rsh 0 1 a)
|
||||||
b (rsh 0 1 b)
|
b (rsh 0 1 b)
|
||||||
c +(c)
|
c +(c)
|
||||||
d (add d (lsh 0 c ?|(=(0 (end 0 1 a)) =(0 (end 0 1 b)))))
|
d %+ add d
|
||||||
|
%^ lsh 0 c
|
||||||
|
?| =(0 (end 0 1 a))
|
||||||
|
=(0 (end 0 1 b))
|
||||||
|
==
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ mix :: binary xor
|
++ mix :: binary xor
|
||||||
@ -976,8 +960,7 @@
|
|||||||
^- @
|
^- @
|
||||||
=+ [c=0 d=0]
|
=+ [c=0 d=0]
|
||||||
|-
|
|-
|
||||||
?: ?&(=(0 a) =(0 b))
|
?: ?&(=(0 a) =(0 b)) d
|
||||||
d
|
|
||||||
%= $
|
%= $
|
||||||
a (rsh 0 1 a)
|
a (rsh 0 1 a)
|
||||||
b (rsh 0 1 b)
|
b (rsh 0 1 b)
|
||||||
@ -995,16 +978,13 @@
|
|||||||
~/ %aor
|
~/ %aor
|
||||||
|= [a=* b=*]
|
|= [a=* b=*]
|
||||||
^- ?
|
^- ?
|
||||||
?: =(a b)
|
?: =(a b) &
|
||||||
&
|
|
||||||
?. ?=(@ a)
|
?. ?=(@ a)
|
||||||
?. ?=(@ b)
|
?: ?=(@ b) |
|
||||||
?: =(-.a -.b)
|
?: =(-.a -.b)
|
||||||
$(a +.a, b +.b)
|
$(a +.a, b +.b)
|
||||||
$(a -.a, b -.b)
|
$(a -.a, b -.b)
|
||||||
|
|
?. ?=(@ b) &
|
||||||
?. ?=(@ b)
|
|
||||||
&
|
|
||||||
|-
|
|-
|
||||||
=+ [c=(end 3 1 a) d=(end 3 1 b)]
|
=+ [c=(end 3 1 a) d=(end 3 1 b)]
|
||||||
?: =(c d)
|
?: =(c d)
|
||||||
@ -1015,16 +995,13 @@
|
|||||||
~/ %dor
|
~/ %dor
|
||||||
|= [a=* b=*]
|
|= [a=* b=*]
|
||||||
^- ?
|
^- ?
|
||||||
?: =(a b)
|
?: =(a b) &
|
||||||
&
|
|
||||||
?. ?=(@ a)
|
?. ?=(@ a)
|
||||||
?. ?=(@ b)
|
?: ?=(@ b) |
|
||||||
?: =(-.a -.b)
|
?: =(-.a -.b)
|
||||||
$(a +.a, b +.b)
|
$(a +.a, b +.b)
|
||||||
$(a -.a, b -.b)
|
$(a -.a, b -.b)
|
||||||
|
|
?. ?=(@ b) &
|
||||||
?. ?=(@ b)
|
|
||||||
&
|
|
||||||
(lth a b)
|
(lth a b)
|
||||||
::
|
::
|
||||||
++ gor :: g-order
|
++ gor :: g-order
|
||||||
@ -1041,11 +1018,9 @@
|
|||||||
|= [a=* b=*]
|
|= [a=* b=*]
|
||||||
^- ?
|
^- ?
|
||||||
?: ?=(@ a)
|
?: ?=(@ a)
|
||||||
?: ?=(@ b)
|
?. ?=(@ b) &
|
||||||
(gor a b)
|
(gor a b)
|
||||||
&
|
?: ?=(@ b) |
|
||||||
?: ?=(@ b)
|
|
||||||
|
|
|
||||||
?: =(-.a -.b)
|
?: =(-.a -.b)
|
||||||
(gor +.a +.b)
|
(gor +.a +.b)
|
||||||
(gor -.a -.b)
|
(gor -.a -.b)
|
||||||
@ -1062,9 +1037,13 @@
|
|||||||
:: section 2cD, insecure hashing ::
|
:: section 2cD, insecure hashing ::
|
||||||
::
|
::
|
||||||
++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler
|
++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler
|
||||||
++ mur :: murmurhash3
|
::
|
||||||
~/ %mur
|
++ mum :: mug with murmur3
|
||||||
|= [key=@ syd=@]
|
~/ %mum
|
||||||
|
|= a=*
|
||||||
|
|^ (trim ?@(a a (mix $(a -.a) (mix 0x7fff.ffff $(a +.a)))))
|
||||||
|
++ spec :: standard murmur3
|
||||||
|
|= [syd=@ key=@]
|
||||||
?> (lte (met 5 syd) 1)
|
?> (lte (met 5 syd) 1)
|
||||||
=+ ^= row
|
=+ ^= row
|
||||||
|= [a=@ b=@]
|
|= [a=@ b=@]
|
||||||
@ -1089,6 +1068,15 @@
|
|||||||
=. goc (row 13 goc)
|
=. goc (row 13 goc)
|
||||||
=. goc (end 5 1 (add 0xe654.6b64 (mul 5 goc)))
|
=. goc (end 5 1 (add 0xe654.6b64 (mul 5 goc)))
|
||||||
$(inx +(inx))
|
$(inx +(inx))
|
||||||
|
::
|
||||||
|
++ trim :: 31-bit nonzero
|
||||||
|
|= key=@
|
||||||
|
=+ syd=0xcafe.babe
|
||||||
|
|- ^- @
|
||||||
|
=+ haz=(spec syd key)
|
||||||
|
=+ ham=(mix (rsh 0 31 haz) (end 0 31 haz))
|
||||||
|
?.(=(0 ham) ham $(syd +(syd)))
|
||||||
|
--
|
||||||
::
|
::
|
||||||
++ mug :: 31bit nonzero FNV1a
|
++ mug :: 31bit nonzero FNV1a
|
||||||
~/ %mug
|
~/ %mug
|
||||||
@ -1115,7 +1103,7 @@
|
|||||||
::
|
::
|
||||||
++ po
|
++ po
|
||||||
~/ %po
|
~/ %po
|
||||||
=+ :- ^= sis :: prefix (left)
|
=+ :- ^= sis :: prefix syllables
|
||||||
'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\
|
'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\
|
||||||
/rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\
|
/rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\
|
||||||
/holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\
|
/holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\
|
||||||
@ -1132,7 +1120,7 @@
|
|||||||
/mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\
|
/mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\
|
||||||
/nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\
|
/nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\
|
||||||
/laptalpitnambonrostonfodponsovnocsorlavmatmipfap'
|
/laptalpitnambonrostonfodponsovnocsorlavmatmipfap'
|
||||||
^= dex :: suffix (right)
|
^= dex :: suffix syllables
|
||||||
'zodnecbudwessevpersutletfulpensytdurwepserwylsun\
|
'zodnecbudwessevpersutletfulpensytdurwepserwylsun\
|
||||||
/rypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\
|
/rypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\
|
||||||
/lunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\
|
/lunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\
|
||||||
@ -1150,28 +1138,18 @@
|
|||||||
/remlysfynwerrycsugnysnyllyndyndemluxfedsedbecmun\
|
/remlysfynwerrycsugnysnyllyndyndemluxfedsedbecmun\
|
||||||
/lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes'
|
/lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes'
|
||||||
|%
|
|%
|
||||||
++ ind ~/ %ind :: prefix to number
|
++ ind ~/ %ind
|
||||||
|= a=@
|
|= a=@
|
||||||
=+ b=0
|
=+ b=0
|
||||||
|- ^- (unit ,@)
|
|- ^- (unit ,@)
|
||||||
?: =(256 b) ~
|
?:(=(256 b) ~ ?:(=(a (tod b)) [~ b] $(b +(b))))
|
||||||
?: =(a (tod b)) [~ b]
|
++ ins ~/ %ins
|
||||||
$(b +(b))
|
|
||||||
++ ins ~/ %ins :: suffix to number
|
|
||||||
|= a=@
|
|= a=@
|
||||||
=+ b=0
|
=+ b=0
|
||||||
|- ^- (unit ,@)
|
|- ^- (unit ,@)
|
||||||
?: =(256 b) ~
|
?:(=(256 b) ~ ?:(=(a (tos b)) [~ b] $(b +(b))))
|
||||||
?: =(a (tos b)) [~ b]
|
++ tod ~/(%tod |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex))))
|
||||||
$(b +(b))
|
++ tos ~/(%tos |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis))))
|
||||||
++ tod ~/ %tod :: number to prefix
|
|
||||||
|= a=@
|
|
||||||
?> (lth a 256)
|
|
||||||
(cut 3 [(mul 3 a) 3] dex)
|
|
||||||
++ tos ~/ %tos :: number to suffix
|
|
||||||
|= a=@
|
|
||||||
?> (lth a 256)
|
|
||||||
(cut 3 [(mul 3 a) 3] sis)
|
|
||||||
--
|
--
|
||||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
:: section 2cF, signed and modular ints ::
|
:: section 2cF, signed and modular ints ::
|
||||||
@ -1207,27 +1185,21 @@
|
|||||||
(new | (add +.c +.d))
|
(new | (add +.c +.d))
|
||||||
++ sun |=(a=@u (mul 2 a)) :: @u to @s
|
++ sun |=(a=@u (mul 2 a)) :: @u to @s
|
||||||
++ syn |=(a=@s =(0 (end 0 1 a))) :: sign test
|
++ syn |=(a=@s =(0 (end 0 1 a))) :: sign test
|
||||||
++ lth |= [a=@s b=@s]
|
++ cmp |= [a=@s b=@s] :: compare
|
||||||
^- ?
|
|
||||||
=+ [c=(old a) d=(old b)]
|
|
||||||
?. -.c
|
|
||||||
(^lth +.d +.c)
|
|
||||||
?. -.d %.n
|
|
||||||
(^lth +.c +.d)
|
|
||||||
++ lte |=([a=@s b=@s] |(=(a b) (lth a b)))
|
|
||||||
++ gte |=([a=@s b=@s] !(lth a b))
|
|
||||||
++ gth |=([a=@s b=@s] !(lte a b))
|
|
||||||
++ cmp
|
|
||||||
|= [a=@s b=@s] :: compare
|
|
||||||
^- @s
|
^- @s
|
||||||
?: =(a b) --0
|
?: =(a b)
|
||||||
?. (syn a)
|
--0
|
||||||
?: (syn b) -1
|
?: (syn a)
|
||||||
?: (gth a b) -1
|
?: (syn b)
|
||||||
|
?: (gth a b)
|
||||||
--1
|
--1
|
||||||
?. (syn b) --1
|
|
||||||
?: (gth a b) --1
|
|
||||||
-1
|
-1
|
||||||
|
--1
|
||||||
|
?: (syn b)
|
||||||
|
-1
|
||||||
|
?: (gth a b)
|
||||||
|
-1
|
||||||
|
--1
|
||||||
--
|
--
|
||||||
++ fe :: modulo bloq
|
++ fe :: modulo bloq
|
||||||
|_ a=bloq
|
|_ a=bloq
|
||||||
@ -1258,28 +1230,14 @@
|
|||||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
:: section 2cG, floating point ::
|
:: section 2cG, floating point ::
|
||||||
::
|
::
|
||||||
++ rlyd
|
++ rlyd |= red=@rd ^- [s=? h=@ f=@ e=(unit tape) n=?]
|
||||||
|= red=@rd
|
|
||||||
^- [s=? h=@ f=@ e=(unit tape) n=?]
|
|
||||||
~& [%rlyd `@ux`red]
|
~& [%rlyd `@ux`red]
|
||||||
=+ s=(sea:rd red)
|
=+ s=(sea:rd red)
|
||||||
=+ negexp==(1 (mod e.s 2))
|
=+ negexp==(1 (mod e.s 2))
|
||||||
[s=(sig:rd red) h=(hol:rd red) f=(fac:rd red) e=(err:rd red) n=negexp]
|
[s=(sig:rd red) h=(hol:rd red) f=(fac:rd red) e=(err:rd red) n=negexp]
|
||||||
++ rlyh
|
++ rlyh |=(reh=@rh ~|(%real-nyet ^-([s=? h=@ f=@ e=(unit tape) n=?] !!)))
|
||||||
|= reh=@rh
|
++ rlyq |=(req=@rq ~|(%real-nyet ^-([s=? h=@ f=@ e=(unit tape) n=?] !!)))
|
||||||
~| %real-nyet
|
++ rlys |=(res=@rs ~|(%real-nyet ^-([s=? h=@ f=@ e=(unit tape) n=?] !!)))
|
||||||
^- [s=? h=@ f=@ e=(unit tape) n=?]
|
|
||||||
!!
|
|
||||||
++ rlyq
|
|
||||||
|= req=@rq
|
|
||||||
~| %real-nyet
|
|
||||||
^- [s=? h=@ f=@ e=(unit tape) n=?]
|
|
||||||
!!
|
|
||||||
++ rlys
|
|
||||||
|= res=@rs
|
|
||||||
~| %real-nyet
|
|
||||||
^- [s=? h=@ f=@ e=(unit tape) n=?]
|
|
||||||
!!
|
|
||||||
++ ryld |= v=[syn=? hol=@ zer=@ fac=@ exp=(unit ,@)] ^- @rd
|
++ ryld |= v=[syn=? hol=@ zer=@ fac=@ exp=(unit ,@)] ^- @rd
|
||||||
?: &(=(hol.v 0) =(zer.v 0) =(fac.v 0))
|
?: &(=(hol.v 0) =(zer.v 0) =(fac.v 0))
|
||||||
(bit:rd (szer:vl:fl 1.023 52 syn.v))
|
(bit:rd (szer:vl:fl 1.023 52 syn.v))
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
$(pax (welp pax /[p.n.r.ark]))
|
$(pax (welp pax /[p.n.r.ark]))
|
||||||
*
|
*
|
||||||
:- (crip "* {(spud pax)}")
|
:- (crip "* {(spud pax)}")
|
||||||
(turn (~(tap by `(map ,@t ,~)`r.ark)) |=([a=@t ~] a))
|
%- sort :_ aor
|
||||||
|
%- turn :_ |=([a=@t ~] a)
|
||||||
|
(~(tap by `(map ,@t ,~)`r.ark))
|
||||||
==
|
==
|
||||||
:- (crip (spud pax))
|
:- (crip (spud pax))
|
||||||
(lore ;;(,@t .^(%cx pax)))
|
(lore ;;(,@t .^(%cx pax)))
|
||||||
|
@ -10,5 +10,7 @@
|
|||||||
=- ?~ q.ark -
|
=- ?~ q.ark -
|
||||||
[(crip (rend pax)) -]
|
[(crip (rend pax)) -]
|
||||||
%- zing
|
%- zing
|
||||||
%+ turn (~(tap by r.ark))
|
%- turn :_ |=(a=@t ^$(pax (weld pax `path`/[a])))
|
||||||
|=([a=@t ~] ^$(pax (weld pax `path`/[a])))
|
%- sort :_ aor
|
||||||
|
%- turn :_ |=([a=@t ~] a)
|
||||||
|
(~(tap by r.ark))
|
||||||
|
@ -139,7 +139,7 @@ pre, .codeblock {
|
|||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
font-size: .9rem;
|
font-size: .8rem;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
|
@ -157,7 +157,7 @@ not a `%da` for now.
|
|||||||
|
|
||||||
`%v` requests the `++dome` at the specified commit.
|
`%v` requests the `++dome` at the specified commit.
|
||||||
|
|
||||||
`%w` requests the current revsion number of the desk.
|
`%w` requests the revsion number of the desk.
|
||||||
|
|
||||||
`%x` requests the file at a specified path at the specified commit. If there
|
`%x` requests the file at a specified path at the specified commit. If there
|
||||||
is no node at that path or if the node has no contents (that is, if `q:ankh` is
|
is no node at that path or if the node has no contents (that is, if `q:ankh` is
|
||||||
@ -296,7 +296,8 @@ stuff before this time.
|
|||||||
simply `p:dojo`, all subscribers to the desk, while in foreign desks this is
|
simply `p:dojo`, all subscribers to the desk, while in foreign desks this is
|
||||||
all the subscribers from our ship to the foreign desk.
|
all the subscribers from our ship to the foreign desk.
|
||||||
|
|
||||||
`ref` is the request manager for the desk.
|
`ref` is the request manager for the desk. For domestic desks, this is null
|
||||||
|
since we handle requests ourselves.
|
||||||
|
|
||||||
`dom` is the actual data in the desk.
|
`dom` is the actual data in the desk.
|
||||||
|
|
||||||
@ -311,7 +312,7 @@ all the subscribers from our ship to the foreign desk.
|
|||||||
== ::
|
== ::
|
||||||
```
|
```
|
||||||
|
|
||||||
This is the request manager for a desk.
|
This is the request manager for a foreign desk.
|
||||||
|
|
||||||
`nix` is one more than the index of the most recent request. Thus, it is the
|
`nix` is one more than the index of the most recent request. Thus, it is the
|
||||||
next available request number.
|
next available request number.
|
||||||
@ -574,6 +575,32 @@ This represents a request for data about a particular desk. If `q` contains a
|
|||||||
`rave`, then this opens a subscription to the desk for that data. If `q` is
|
`rave`, then this opens a subscription to the desk for that data. If `q` is
|
||||||
null, then this tells clay to cancel the subscription along this duct.
|
null, then this tells clay to cancel the subscription along this duct.
|
||||||
|
|
||||||
|
###`++riot`, response
|
||||||
|
|
||||||
|
```
|
||||||
|
++ riot (unit rant) :: response/complete
|
||||||
|
```
|
||||||
|
|
||||||
|
A riot is a response to a subscription. If null, the subscription has been
|
||||||
|
completed, and no more responses will be sent. Otherwise, the `rant` is the
|
||||||
|
produced data.
|
||||||
|
|
||||||
|
###`++rant`, response data
|
||||||
|
|
||||||
|
```
|
||||||
|
++ rant :: namespace binding
|
||||||
|
$: p=[p=care q=case r=@tas] :: clade release book
|
||||||
|
q=path :: spur
|
||||||
|
r=* :: data
|
||||||
|
== ::
|
||||||
|
```
|
||||||
|
|
||||||
|
This is the data at a particular node in the filesystem. `p.p` specifies the
|
||||||
|
type of data that was requested (and is produced). `q.p` gives the specific
|
||||||
|
version reported (since a range of versions may be requested in a
|
||||||
|
subscription). `r.p` is the desk. `q` is the path to the filesystem node.
|
||||||
|
`r` is the data itself (in the format specified by `p.p`).
|
||||||
|
|
||||||
Interface
|
Interface
|
||||||
---------
|
---------
|
||||||
|
|
||||||
@ -677,3 +704,311 @@ another ship asks for a file from us, that request comes to us in the form of a
|
|||||||
This is a request for information about a particular desk. This is, in its
|
This is a request for information about a particular desk. This is, in its
|
||||||
most general form, a subscription, though in many cases it is the trivial case
|
most general form, a subscription, though in many cases it is the trivial case
|
||||||
of a subscription -- a read. See `++riff` for the format of the request.
|
of a subscription -- a read. See `++riff` for the format of the request.
|
||||||
|
|
||||||
|
Lifecycle of a Local Read
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
There are two real types of interaction with a filesystem: you can read, and
|
||||||
|
you can write. We'll describe each process, detailing both the flow of control
|
||||||
|
followed by the kernel and the algorithms involved. The simpler case is that
|
||||||
|
of the read, so we'll begin with that.
|
||||||
|
|
||||||
|
When a vane or an application wishes to read a file from the filesystem, it
|
||||||
|
sends a `%warp` kiss, as described above. Of course, you may request a file on
|
||||||
|
another ship and, being a global filesystem, clay will happily produce it for
|
||||||
|
you. That code pathway will be described in another section; here, we will
|
||||||
|
restrict ourselves to examining the case of a read from a ship on our own pier.
|
||||||
|
|
||||||
|
The kiss can request either a single version of a file or a range of versions
|
||||||
|
of a desk. We'll trace through both paths at once.
|
||||||
|
|
||||||
|
As in all vanes, a kiss enters clay via a call to `++call`. Scanning through
|
||||||
|
the arm, we quickly see where `%warp` is handled.
|
||||||
|
|
||||||
|
```
|
||||||
|
?: =(p.p.q.hic q.p.q.hic)
|
||||||
|
=+ une=(un p.p.q.hic now ruf)
|
||||||
|
=+ wex=(di:une p.q.q.hic)
|
||||||
|
=+ ^= wao
|
||||||
|
?~ q.q.q.hic
|
||||||
|
(ease:wex hen)
|
||||||
|
(eave:wex hen u.q.q.q.hic)
|
||||||
|
=+ ^= woo
|
||||||
|
abet:wao
|
||||||
|
[-.woo abet:(pish:une p.q.q.hic +.woo ran.wao)]
|
||||||
|
```
|
||||||
|
|
||||||
|
We're following the familar patern of producing a list of moves and an updated
|
||||||
|
state. In this case, the state is `++raft`.
|
||||||
|
|
||||||
|
We first check to see if the sending and receiving ships are the same. If
|
||||||
|
they're not, then this is a request for data on another ship. We describe that
|
||||||
|
process later. Here, we discuss only the case of a local read.
|
||||||
|
|
||||||
|
At a high level, the call to `++un` sets up the core for the domestic ship that
|
||||||
|
contains the files we're looking for. The call to `++di` sets up the core for
|
||||||
|
the particular desk we're referring to.
|
||||||
|
|
||||||
|
After this, we perform the actual request. If there is no rave in the riff,
|
||||||
|
then that means we are cancelling a request, so we call `++ease:de`.
|
||||||
|
Otherwise, we start a subscription with `++eave:de`. We call `++abet:de` to
|
||||||
|
resolve our various types of output into actual moves. We produce the moves we
|
||||||
|
found above and the `++un` core resolved with `++pish:un` (putting the modified
|
||||||
|
desk in the room) and `++abet:un` (putting the modified room in the raft).
|
||||||
|
|
||||||
|
Much of this is fairly straightforward, so we'll only describe `++ease`,
|
||||||
|
`++eave`, and `++abet:de`. Feel free to look up the code to the other steps --
|
||||||
|
it should be easy to follow.
|
||||||
|
|
||||||
|
Although it's called last, it's usually worth examining `++abet` first, since
|
||||||
|
it defines in what ways we can cause side effects. Let's do that, and also a
|
||||||
|
few of the lines at the beginning of `++de`.
|
||||||
|
|
||||||
|
```
|
||||||
|
=| yel=(list ,[p=duct q=gift])
|
||||||
|
=| byn=(list ,[p=duct q=riot])
|
||||||
|
=| vag=(list ,[p=duct q=gift])
|
||||||
|
=| say=(list ,[p=duct q=path r=ship s=[p=@ud q=riff]])
|
||||||
|
|%
|
||||||
|
++ abet
|
||||||
|
^- [(list move) rede]
|
||||||
|
:_ red
|
||||||
|
;: weld
|
||||||
|
%+ turn (flop yel)
|
||||||
|
|=([a=duct b=gift] [hun %give b])
|
||||||
|
::
|
||||||
|
%+ turn (flop byn)
|
||||||
|
|=([a=duct b=riot] [a %give [%writ b]])
|
||||||
|
::
|
||||||
|
%+ turn (flop vag)
|
||||||
|
|=([a=duct b=gift] [a %give b])
|
||||||
|
::
|
||||||
|
%+ turn (flop say)
|
||||||
|
|= [a=duct b=path c=ship d=[p=@ud q=riff]]
|
||||||
|
:- a
|
||||||
|
[%pass b %a %want [who c] [%q %re p.q.d (scot %ud p.d) ~] q.d]
|
||||||
|
==
|
||||||
|
```
|
||||||
|
|
||||||
|
This is very simple code. We see there are exactly four different kinds of
|
||||||
|
side effects we can generate.
|
||||||
|
|
||||||
|
In `yel` we put gifts that we wish to be sent along the `hun:room` duct to
|
||||||
|
dill. See the documentation for `++room` above. This is how we display
|
||||||
|
messages to the terminal.
|
||||||
|
|
||||||
|
In `byn` we put riots that we wish returned to subscribers. Recall that a riot
|
||||||
|
is a response to a subscription. These are returned to our subscribers in the
|
||||||
|
form of a `%writ` gift.
|
||||||
|
|
||||||
|
In `vag` we put gifts along with the ducts on which to send them. This allows
|
||||||
|
us to produce arbitrary gifts, but in practice this is only used to produce
|
||||||
|
`%ergo` gifts.
|
||||||
|
|
||||||
|
In `say` we put messages we wish to pass to ames. These messages are used to
|
||||||
|
request information from clay on other piers. We must provide not only the
|
||||||
|
duct and the request (the riff), but also the return path, the other ship to
|
||||||
|
talk to, and the sequence number of the request.
|
||||||
|
|
||||||
|
Now that we know what kinds of side effects we may have, we can jump into the
|
||||||
|
handling of requests.
|
||||||
|
|
||||||
|
```
|
||||||
|
++ ease :: release request
|
||||||
|
|= hen=duct
|
||||||
|
^+ +>
|
||||||
|
=. qyx (~(del by qyx) hen)
|
||||||
|
?~ ref +>
|
||||||
|
|- ^+ +>+.$
|
||||||
|
=+ nux=(~(get by fod.u.ref) hen)
|
||||||
|
?~ nux +>+.$
|
||||||
|
%= +>+.$
|
||||||
|
say [[hen [(scot %ud u.nux) ~] for [u.nux syd ~]] say]
|
||||||
|
fod.u.ref (~(del by fod.u.ref) hen)
|
||||||
|
bom.u.ref (~(del by bom.u.ref) u.nux)
|
||||||
|
==
|
||||||
|
```
|
||||||
|
|
||||||
|
This is called when we're cancelling a subscription. First, we remove the duct
|
||||||
|
from our map of subscribers. For domestic desks, `ref` is null, so we're done.
|
||||||
|
Although we said we're not going to talk about foreign requests yet, it's easy
|
||||||
|
to see that for foreign desks, we cancel any outstanding requests for this duct
|
||||||
|
and send a message over ames to the other ship telling them to cancel the
|
||||||
|
subscription.
|
||||||
|
|
||||||
|
The more interesting case is, of course, when we're not cancelling a
|
||||||
|
subscription but starting one.
|
||||||
|
|
||||||
|
```
|
||||||
|
++ eave :: subscribe
|
||||||
|
|= [hen=duct rav=rave]
|
||||||
|
^+ +>
|
||||||
|
?- -.rav
|
||||||
|
&
|
||||||
|
?: &(=(p.p.rav %u) !=(p.q.p.rav now))
|
||||||
|
~& [%clay-fail p.q.p.rav %now now]
|
||||||
|
!!
|
||||||
|
=+ ver=(aver p.rav)
|
||||||
|
?~ ver
|
||||||
|
(duce hen rav)
|
||||||
|
?~ u.ver
|
||||||
|
(blub hen)
|
||||||
|
(blab hen p.rav u.u.ver)
|
||||||
|
```
|
||||||
|
|
||||||
|
There are two types of subscriptions -- either we're requesting a single file
|
||||||
|
or we're requesting a range of versions of a desk. We'll dicuss the simpler
|
||||||
|
case first.
|
||||||
|
|
||||||
|
First, we check that we're not requesting the `rang` from any time other than
|
||||||
|
the present. Since we don't store that information for any other time, we
|
||||||
|
can't produce it in a referentially transparent manner for any time other than
|
||||||
|
the present.
|
||||||
|
|
||||||
|
Then, we try to read the requested `mood` `p.rav`. If we can't access the
|
||||||
|
request data right now, we call `++duce` to put the request in our queue to be
|
||||||
|
satisfied when the information becomes available. The code for `++duce` is
|
||||||
|
nearly the exact inverse of `++ease`, which in the case of a domestic desk is
|
||||||
|
very simple -- we simply put the duct and rave into `qyx`. This case occurs
|
||||||
|
when we make a request for a case whose (1) date is after the current date, (2)
|
||||||
|
number is after the current number, or (3) label is not yet used.
|
||||||
|
|
||||||
|
If `++aver` returned `[~ ~]`, then we cancel the subscription. This occurs
|
||||||
|
when we make (1) a `%x` request for a file that does not exist, (2) a `%w`
|
||||||
|
request with a case that is not a number, or (3) a `%w` request with a nonempty
|
||||||
|
path. The `++blub` is exactly what you would expect it to be.
|
||||||
|
|
||||||
|
```
|
||||||
|
++ blub :: ship stop
|
||||||
|
|= hen=duct
|
||||||
|
%_(+> byn [[hen ~] byn])
|
||||||
|
```
|
||||||
|
|
||||||
|
We notify the duct that we're cancelling their subscription since it isn't
|
||||||
|
satisfiable.
|
||||||
|
|
||||||
|
Otherwise, we have received the desired information, so we send it on to the
|
||||||
|
subscriber with `++blab`.
|
||||||
|
|
||||||
|
```
|
||||||
|
++ blab :: ship result
|
||||||
|
|= [hen=duct mun=mood dat=*]
|
||||||
|
^+ +>
|
||||||
|
+>(byn [[hen ~ [p.mun q.mun syd] r.mun dat] byn])
|
||||||
|
```
|
||||||
|
|
||||||
|
The most interesting arm called in `++eave` is, of course, `++aver`, where we
|
||||||
|
actually try to read the data.
|
||||||
|
|
||||||
|
```
|
||||||
|
++ aver :: read
|
||||||
|
|= mun=mood
|
||||||
|
^- (unit (unit ,*))
|
||||||
|
?: &(=(p.mun %u) !=(p.q.mun now)) :: prevent bad things
|
||||||
|
~& [%clay-fail p.q.mun %now now]
|
||||||
|
!!
|
||||||
|
=+ ezy=?~(ref ~ (~(get by haw.u.ref) mun))
|
||||||
|
?^ ezy ezy
|
||||||
|
=+ nao=(~(aeon ze lim dom ran) q.mun)
|
||||||
|
:: ~& [%aver-mun nao [%from syd lim q.mun]]
|
||||||
|
?~(nao ~ [~ (~(avid ze lim dom ran) u.nao mun)])
|
||||||
|
```
|
||||||
|
|
||||||
|
We check immediately that we're not requesting the `rang` for any time other
|
||||||
|
than the present.
|
||||||
|
|
||||||
|
If this is a foreign desk, then we check our cache for the specific request.
|
||||||
|
If either this is a domestic desk or we don't have the request in our cache,
|
||||||
|
then we have to actually go read the data from our dome.
|
||||||
|
|
||||||
|
We need to do two things. First, we try to find the number of the commit
|
||||||
|
specified by the given case, and then we try to get the data there.
|
||||||
|
|
||||||
|
Here, we jump into `arvo/zuse.hoon`, which is where much of the algorithmic
|
||||||
|
code is stored, as opposed to the clay interface, which is stored in
|
||||||
|
`arvo/clay.hoon`. We examine `++aeon:ze`.
|
||||||
|
|
||||||
|
```
|
||||||
|
++ aeon :: aeon:ze
|
||||||
|
|= lok=case :: act count through
|
||||||
|
^- (unit ,@ud)
|
||||||
|
?- -.lok
|
||||||
|
%da
|
||||||
|
?: (gth p.lok lim) ~
|
||||||
|
|- ^- (unit ,@ud)
|
||||||
|
?: =(0 let) [~ 0] :: avoid underflow
|
||||||
|
?: %+ gte p.lok
|
||||||
|
=< t
|
||||||
|
%- ~(got by hut)
|
||||||
|
%- ~(got by hit)
|
||||||
|
let
|
||||||
|
[~ let]
|
||||||
|
$(let (dec let))
|
||||||
|
::
|
||||||
|
%tas (~(get by lab) p.lok)
|
||||||
|
%ud ?:((gth p.lok let) ~ [~ p.lok])
|
||||||
|
==
|
||||||
|
```
|
||||||
|
|
||||||
|
We handle each type of `case` differently. The latter two types are easy.
|
||||||
|
|
||||||
|
If we're requesting a revision by label, then we simply look up the requested
|
||||||
|
label in `lab` from the given dome. If it exists, that is our number; else we
|
||||||
|
produce null, indicating the requested revision does not yet exist.
|
||||||
|
|
||||||
|
If we're requesting a revision by number, we check if we've yet reached that
|
||||||
|
number. If so, we produce the number; else we produce null.
|
||||||
|
|
||||||
|
If we're requesting a revision by date, we check first if the date is in the
|
||||||
|
future, returning null if so. Else we start from the most recent revision and
|
||||||
|
scan backwards until we find the first revision committed before that date, and
|
||||||
|
we produce that. If we requested a date before any revisions were committed,
|
||||||
|
we produce `0`.
|
||||||
|
|
||||||
|
Assuming we got a valid version number, `++aver` calls `++avid:ze`, which reads
|
||||||
|
the requested data at the given revision.
|
||||||
|
|
||||||
|
```
|
||||||
|
++ avid :: avid:ze
|
||||||
|
|= [oan=@ud mun=mood] :: seek and read
|
||||||
|
^- (unit)
|
||||||
|
?: &(?=(%w p.mun) !?=(%ud -.q.mun)) :: NB only for speed
|
||||||
|
?^(r.mun ~ [~ oan])
|
||||||
|
(auto:(argo oan) mun)
|
||||||
|
```
|
||||||
|
|
||||||
|
If we're requesting the revision number with a case other than by number, then
|
||||||
|
we go ahead and just produce the number we were given. Otherwise, we call
|
||||||
|
`++argo` to rewind our state to the given revision, and then we call `++auto`
|
||||||
|
to get the requested information.
|
||||||
|
|
||||||
|
```
|
||||||
|
++ argo :: argo:ze
|
||||||
|
|= oan=@ud :: rewind to aeon
|
||||||
|
^+ +>
|
||||||
|
?: =(let oan) +>
|
||||||
|
?: (gth oan let) !! :: don't have this version
|
||||||
|
+>(ank (azel q:(need (~(get by hut) (need (~(get by hit) oan))))), let oan)
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
=+ nab=(~(aeon ze lim dom ran) p.p.rav)
|
||||||
|
?~ nab
|
||||||
|
?> =(~ (~(aeon ze lim dom ran) q.p.rav))
|
||||||
|
(duce hen rav)
|
||||||
|
=+ huy=(~(aeon ze lim dom ran) q.p.rav)
|
||||||
|
?: &(?=(^ huy) |((lth u.huy u.nab) &(=(0 u.huy) =(0 u.nab))))
|
||||||
|
(blub hen)
|
||||||
|
=+ top=?~(huy let.dom u.huy)
|
||||||
|
=+ fud=(~(gack ze lim dom ran) u.nab let.dom)
|
||||||
|
=. +>.$ (bleb hen u.nab fud)
|
||||||
|
?^ huy
|
||||||
|
(blub hen)
|
||||||
|
=+ ^= ptr ^- case
|
||||||
|
[%ud +(let.dom)]
|
||||||
|
(duce hen `rave`[%| ptr q.p.rav])
|
||||||
|
==
|
||||||
|
```
|
||||||
|
|
||||||
|
(this is from `++eave`)
|
||||||
|
@ -238,7 +238,7 @@ we put:
|
|||||||
:::: /hoon/three/mad/fab/pub
|
:::: /hoon/three/mad/fab/pub
|
||||||
::
|
::
|
||||||
/= hello /: /===/pub/fab/mad/res/hello /hymn/
|
/= hello /: /===/pub/fab/mad/res/hello /hymn/
|
||||||
:
|
::
|
||||||
:::: ~tasfyn-partyv
|
:::: ~tasfyn-partyv
|
||||||
::
|
::
|
||||||
::
|
::
|
||||||
|
Loading…
Reference in New Issue
Block a user