From 91b1d718a3de519e873b8d4db4cbfedddcf9f263 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 2 Sep 2014 12:23:39 -0700 Subject: [PATCH 1/5] Revert "some hoon.hoon edits" This reverts commit c9670e2a48eaf2a089bd4dd2d9f47f5f38d42a91. --- arvo/hoon.hoon | 247 +++++++++++++++++++++++-------------------------- 1 file changed, 115 insertions(+), 132 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index ceb786d4c..fe5769a02 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -50,22 +50,28 @@ [ven=term pro=term kel=@] :: vendor and product [ven=term pro=term ver=@ kel=@] :: all of the above == :: +++ claw $% [%ash p=twig] :: XX not used + [%elm p=twig] :: + [%oak ~] :: + [%yew p=(map term claw)] :: + == :: ++ clue ,[p=axis q=chum r=tyre] :: battery definition -++ coil $: p=?(%gold %iron %lead %zinc) :: core type +++ coat ,[p=path q=vase] :: +++ coil $: p=?(%gold %iron %lead %zinc) :: q=type :: r=[p=?(~ ^) q=(map term foot)] :: == :: -++ coin $% [%$ p=dime] :: +++ coin $% [%$ p=dime] :: [%blob p=*] :: [%many p=(list coin)] :: == :: ++ cord ,@t :: text atom (UTF-8) ++ date ,[[a=? y=@ud] m=@ud t=tarp] :: parsed date -++ dime ,[p=@ta q=@] :: +++ dime ,[p=@ta q=@] :: ++ dram $% [| p=(map ,@tas dram)] :: simple unix dir [& p=@ud q=@] :: == :: -++ each |*([a=$+(* *) b=$+(* *)] $%([& p=a] [| p=b])) :: either a or b +++ each |*([a=$+(* *) b=$+(* *)] $%([& p=a] [| p=b])) :: ++ edge ,[p=hair q=(unit ,[p=* q=nail])] :: parsing output ++ foot $% [%ash p=twig] :: dry arm, geometric [%elm p=twig] :: wet arm, generic @@ -73,7 +79,15 @@ [%yew p=(map term foot)] :: XX not used == :: ++ gate $+(* *) :: general gate +++ gear |* a=_,* :: XX list generator + $_ :: + =| b=* :: + |? :: + ?@ b :: + ~ :: + [i=(a -.b) t=^?(..$(b +.b))] :: ++ hair ,[p=@ud q=@ud] :: parsing trace +++ hapt (list ,@ta) :: XX not used ++ like |* a=_,* :: generic edge |= b=_`*`[(hair) ~] :: :- p=(hair -.b) :: @@ -108,7 +122,7 @@ ++ pint ,[p=[p=@ q=@] q=[p=@ q=@]] :: line/column range ++ pole |* a=_,* :: nameless list $|(~ [a (pole a)]) :: -++ port $: p=axis :: +++ port $: p=axis :: $= q :: $% [%& p=type] :: [%| p=axis q=(list ,[p=type q=foot])] :: @@ -127,6 +141,7 @@ == :: ++ qual |* [a=$+(* *) b=$+(* *) c=$+(* *) d=$+(* *)] :: just a quadruple ,[p=a q=b r=c s=d] :: +:: ++ rege $| ?(%dote %ende %sart %empt %boun %bout) :: parsed regex $% [%lite p=char] :: literal [%pair p=rege q=rege] :: ordering @@ -149,14 +164,8 @@ ++ spot ,[p=path q=pint] :: range in file ++ tang (list tank) :: general error ++ tank $% [%leaf p=tape] :: printing formats - $: %palm :: - p=[p=tape q=tape r=tape s=tape] :: - q=(list tank) :: - == :: - $: %rose :: - p=[p=tape q=tape r=tape] :: - q=(list tank) :: - == :: + [%palm p=[p=tape q=tape r=tape s=tape] q=(list tank)] + [%rose p=[p=tape q=tape r=tape] q=(list tank)] == :: ++ tape (list char) :: like a string ++ term ,@tas :: Hoon ASCII subset @@ -195,17 +204,17 @@ ++ twig $& [p=twig q=twig] :: $% :: [%$ p=axis] :: simple leg - :: :::::: tiling + :: :: [%bccb p=tile] :: bunt a tile [%bccm p=tile] :: clam a tile [%bcpt p=wing q=tile] :: whip p into q [%bctr p=tile] :: static bunt w/ ^~ [%bczp p=base] :: bunt an axil - :: :::::: 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 [%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 [%brhp p=twig] :: kick dry %gold trap [%brls p=tile q=twig] :: dry %iron gate @@ -213,7 +222,7 @@ [%brtr p=tile q=twig] :: vulcan. wet gate [%brts p=tile q=twig] :: dry %gold gate [%brwt p=twig] :: dry %lead trap - :: :::::: tuples + :: :: [%clcb p=twig q=twig] :: [q p] [%clcn p=tusk] :: [[p ~] ~] [%clfs p=twig] :: [%$ [%$ p ~] ~] @@ -222,19 +231,20 @@ [%clls p=twig q=twig r=twig] :: [p q r] [%clsg p=tusk] :: [p ~] [%cltr p=tusk] :: p as a tuple - :: :::::: invocations + [%clzz p=tusk] :: macro + :: :: [%cncb p=wing q=tram] :: %=, then cast to p [%cncl p=twig q=twig] :: pull $.p w/ sample q [%cndt p=twig q=twig] :: %-(q p) [%cnhp p=twig q=tusk] :: slam p w/ sample q - [%cntr p=wing q=twig r=tram] :: pull p.q w/ changes + [%cntr p=wing q=twig r=tram] :: [%cnkt p=twig q=twig r=twig s=twig] :: slam p w/ %*(q r s) [%cnls p=twig q=twig r=twig] :: slam p w/ %*(q r) [%cnsg p=wing q=twig r=twig] :: pull p from q with r [%cnts p=wing q=tram] :: eval. p w/ q changes [%cnzy p=term] :: pulls limb p [%cnzz p=wing] :: pulls p - :: :::::: nock + :: :: [%dtkt p=twig] :: nock 11 data skyhook [%dtls p=twig] :: nock 4 increment [%dtzy p=term q=@] :: atom constant @@ -242,9 +252,9 @@ [%dttr p=twig q=twig] :: nock p w/ formula q [%dtts p=twig q=twig] :: nock 5 equality test [%dtwt p=twig] :: nock 3 cell test - :: :::::: prettyprinting - [%hxgl p=tusk] :: prettyprint tape - [%hxgr p=tusk] :: prettyprint tank + :: :: + [%hxgl p=tusk] :: slam noah w/ !>:*(p) + [%hxgr p=tusk] :: slam cain w/ !>:*(p) :: :::::: type conversion [%ktbr p=twig] :: %gold core to %iron [%ktdt p=twig q=twig] :: cast q to type (p q) @@ -268,13 +278,13 @@ [%sgts p=twig q=twig] :: avoid duplication [%sgwt p=@ud q=twig r=twig s=twig] :: hint iff q is yes [%sgzp p=twig q=twig] :: type in stacktrace - :: :::::: miscellaneous + :: :: miscellaneous [%smcl p=twig q=tusk] :: binary to n-ary - [%smdt p=twig q=tusk] :: + [%smdt p=twig q=tusk] :: [%smdq p=(list beer)] :: assemble string [%smsg p=twig q=tusk] :: gonads [%smsm p=twig q=twig] :: make sure q is a p - :: :::::: compositions + :: :: compositions [%tsbr p=tile q=twig] :: push bunt: =+(_p q) [%tscl p=tram q=twig] :: p changes, then q [%tscn p=twig q=twig] :: XX not used @@ -295,7 +305,7 @@ [%wthz p=tiki q=tine] :: tiki %wthp [%wtcl p=twig q=twig r=twig] :: if p, then q, else r [%wtdt p=twig q=twig r=twig] :: unless, ?:(p r q) - [%wtkt p=wing q=twig r=twig] :: if p is a cell + [%wtkt p=wing q=twig r=twig] :: if p is not its bunt [%wtkz p=tiki q=twig r=twig] :: tiki %wtkt [%wtgl p=twig q=twig] :: assert |, ?:(p !! q) [%wtgr p=twig q=twig] :: assert &, ?:(p q !!) @@ -400,7 +410,7 @@ ++ vise ,[p=typo q=*] :: old vase ++ wall (list tape) :: 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) $% [%atom p=term] :: [%core p=(list ,@ta) q=wine] :: @@ -513,12 +523,7 @@ ~/ %lth |= [a=@ b=@] ^- ? - ?& !=(a b) - |- - ?| =(0 a) - ?& !=(0 b) - $(a (dec a), b (dec b)) - == == == + &(!=(a b) |-(|(=(0 a) &(!=(0 b) $(a (dec a), b (dec b)))))) :: ++ mas :: tree body ~/ %mas @@ -745,47 +750,52 @@ |- ^+ [p=a q=a] ?~ a [~ ~] =+ c=$(a t.a) - ?: (b i.a) - [[i.a p.c] q.c] - [p.c [i.a q.c]] + ?:((b i.a) [[i.a p.c] q.c] [p.c [i.a q.c]]) :: ++ skim :: only ~/ %skim |* [a=(list) b=_|=(p=* .?(p))] - |- ^+ a - ?~ a ~ - ?. (b i.a) $(a t.a) - [i.a $(a t.a)] + |- + ^+ a + ?~ a + ~ + ?:((b i.a) [i.a $(a t.a)] $(a t.a)) :: ++ skip :: except ~/ %skip |* [a=(list) b=_|=(p=* .?(p))] - |- ^+ a - ?~ a ~ - ?: (b i.a) $(a t.a) - [i.a $(a t.a)] + |- + ^+ a + ?~ a + ~ + ?:((b i.a) $(a t.a) [i.a $(a t.a)]) :: ++ scag :: prefix ~/ %scag |* [a=@ b=(list)] |- ^+ b - ?: |(?=(~ b) =(0 a)) ~ + ?: |(?=(~ b) =(0 a)) + ~ [i.b $(b t.b, a (dec a))] :: ++ slag :: suffix ~/ %slag |* [a=@ b=(list)] |- ^+ b - ?: =(0 a) b - ?~ b ~ + ?: =(0 a) + b + ?~ b + ~ $(b t.b, a (dec a)) :: ++ snag :: index ~/ %snag |* [a=@ b=(list)] |- - ?~ b ~|('snag-fail' !!) - ?: =(0 a) i.b + ?~ b + ~|('snag-fail' !!) + ?: =(0 a) + i.b $(b t.b, a (dec a)) :: ++ sort :: quicksort @@ -807,7 +817,8 @@ ~/ %turn |* [a=(list) b=_,*] |- - ?~ a ~ + ?~ a + ~ [i=(b i.a) t=$(a t.a)] :: ++ weld :: concatenate @@ -865,7 +876,8 @@ ~/ %can |= [a=bloq b=(list ,[p=@ q=@])] ^- @ - ?~ b 0 + ?~ b + 0 (mix (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b))) :: ++ cat :: concatenate @@ -903,7 +915,8 @@ ^- @ =+ c=0 |- - ?: =(0 b) c + ?: =(0 b) + c $(b (rsh a 1 b), c +(c)) :: ++ rap :: assemble nonzero @@ -1062,7 +1075,7 @@ :: section 2cD, insecure hashing :: :: ++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler -++ mur :: murmurhash3 +++ mur ~/ %mur |= [key=@ syd=@] ?> (lte (met 5 syd) 1) @@ -1115,24 +1128,24 @@ :: ++ po ~/ %po - =+ :- ^= sis :: prefix (left) - 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\ - /rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\ - /holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\ - /losdilforpilramtirwintadbicdifrocwidbisdasmidlop\ - /rilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\ - /ritpodmottamtolsavposnapnopsomfinfonbanporworsip\ - /ronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\ - /sivtagpadsaldivdactansidfabtarmonranniswolmispal\ - /lasdismaprabtobrollatlonnodnavfignomnibpagsopral\ - /bilhaddocridmocpacravripfaltodtiltinhapmicfanpat\ - /taclabmogsimsonpinlomrictapfirhasbosbatpochactid\ - /havsaplindibhosdabbitbarracparloddosbortochilmac\ - /tomdigfilfasmithobharmighinradmashalraglagfadtop\ - /mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\ - /nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\ - /laptalpitnambonrostonfodponsovnocsorlavmatmipfap' - ^= dex :: suffix (right) + =+ :- ^= sis + 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\ + /rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\ + /holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\ + /losdilforpilramtirwintadbicdifrocwidbisdasmidlop\ + /rilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\ + /ritpodmottamtolsavposnapnopsomfinfonbanporworsip\ + /ronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\ + /sivtagpadsaldivdactansidfabtarmonranniswolmispal\ + /lasdismaprabtobrollatlonnodnavfignomnibpagsopral\ + /bilhaddocridmocpacravripfaltodtiltinhapmicfanpat\ + /taclabmogsimsonpinlomrictapfirhasbosbatpochactid\ + /havsaplindibhosdabbitbarracparloddosbortochilmac\ + /tomdigfilfasmithobharmighinradmashalraglagfadtop\ + /mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\ + /nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\ + /laptalpitnambonrostonfodponsovnocsorlavmatmipfap' + ^= dex 'zodnecbudwessevpersutletfulpensytdurwepserwylsun\ /rypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\ /lunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\ @@ -1150,28 +1163,18 @@ /remlysfynwerrycsugnysnyllyndyndemluxfedsedbecmun\ /lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes' |% - ++ ind ~/ %ind :: prefix to number + ++ ind ~/ %ind |= a=@ =+ b=0 |- ^- (unit ,@) - ?: =(256 b) ~ - ?: =(a (tod b)) [~ b] - $(b +(b)) - ++ ins ~/ %ins :: suffix to number + ?:(=(256 b) ~ ?:(=(a (tod b)) [~ b] $(b +(b)))) + ++ ins ~/ %ins |= a=@ =+ b=0 |- ^- (unit ,@) - ?: =(256 b) ~ - ?: =(a (tos b)) [~ b] - $(b +(b)) - ++ 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) + ?:(=(256 b) ~ ?:(=(a (tos b)) [~ b] $(b +(b)))) + ++ tod ~/(%tod |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex)))) + ++ tos ~/(%tos |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis)))) -- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 2cF, signed and modular ints :: @@ -1207,27 +1210,21 @@ (new | (add +.c +.d)) ++ sun |=(a=@u (mul 2 a)) :: @u to @s ++ syn |=(a=@s =(0 (end 0 1 a))) :: sign test - ++ lth |= [a=@s b=@s] - ^- ? - =+ [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 - ?: =(a b) --0 - ?. (syn a) - ?: (syn b) -1 - ?: (gth a b) -1 - --1 - ?. (syn b) --1 - ?: (gth a b) --1 - -1 + ++ cmp |= [a=@s b=@s] :: compare + ^- @s + ?: =(a b) + --0 + ?: (syn a) + ?: (syn b) + ?: (gth a b) + --1 + -1 + --1 + ?: (syn b) + -1 + ?: (gth a b) + -1 + --1 -- ++ fe :: modulo bloq |_ a=bloq @@ -1258,28 +1255,14 @@ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 2cG, floating point :: :: -++ rlyd - |= red=@rd - ^- [s=? h=@ f=@ e=(unit tape) n=?] - ~& [%rlyd `@ux`red] - =+ s=(sea:rd red) - =+ negexp==(1 (mod e.s 2)) - [s=(sig:rd red) h=(hol:rd red) f=(fac:rd red) e=(err:rd red) n=negexp] -++ rlyh - |= reh=@rh - ~| %real-nyet - ^- [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=?] - !! +++ rlyd |= red=@rd ^- [s=? h=@ f=@ e=(unit tape) n=?] + ~& [%rlyd `@ux`red] + =+ s=(sea:rd red) + =+ negexp==(1 (mod e.s 2)) + [s=(sig:rd red) h=(hol:rd red) f=(fac:rd red) e=(err:rd red) n=negexp] +++ rlyh |=(reh=@rh ~|(%real-nyet ^-([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 ?: &(=(hol.v 0) =(zer.v 0) =(fac.v 0)) (bit:rd (szer:vl:fl 1.023 52 syn.v)) From 9fbfb51a6dbede50f77a1d407a6e96025ebd3f86 Mon Sep 17 00:00:00 2001 From: ault011 Date: Tue, 2 Sep 2014 12:54:47 -0700 Subject: [PATCH 2/5] Fixed ford-advanced doc typo --- main/pub/src/doc/say/arvo/5.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/pub/src/doc/say/arvo/5.md b/main/pub/src/doc/say/arvo/5.md index bf8fb25be..b577e8ed5 100644 --- a/main/pub/src/doc/say/arvo/5.md +++ b/main/pub/src/doc/say/arvo/5.md @@ -238,7 +238,7 @@ we put: :::: /hoon/three/mad/fab/pub :: /= hello /: /===/pub/fab/mad/res/hello /hymn/ - : + :: :::: ~tasfyn-partyv :: :: From ad83c317534bf6c0d354d7dde325e81bbb952e67 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 2 Sep 2014 13:13:12 -0700 Subject: [PATCH 3/5] Ready to switch over mug. --- arvo/hoon.hoon | 67 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index fe5769a02..f1e85cdb5 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -1075,33 +1075,46 @@ :: section 2cD, insecure hashing :: :: ++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler -++ mur - ~/ %mur - |= [key=@ syd=@] - ?> (lte (met 5 syd) 1) - =+ ^= row - |= [a=@ b=@] - (con (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) - =+ mow=|=([a=@ b=@] (end 5 1 (mul a b))) - =+ len=(met 5 key) - =- =. goc (mix goc len) - =. goc (mix goc (rsh 4 1 goc)) - =. goc (mow goc 0x85eb.ca6b) - =. goc (mix goc (rsh 0 13 goc)) - =. goc (mow goc 0xc2b2.ae35) - (mix goc (rsh 4 1 goc)) - ^= goc - =+ [inx=0 goc=syd] - |- ^- @ - ?: =(inx len) goc - =+ kop=(cut 5 [inx 1] key) - =. kop (mow kop 0xcc9e.2d51) - =. kop (row 15 kop) - =. kop (mow kop 0x1b87.3593) - =. goc (mix kop goc) - =. goc (row 13 goc) - =. goc (end 5 1 (add 0xe654.6b64 (mul 5 goc))) - $(inx +(inx)) +:: +++ mum :: mug with murmur3 + ~/ %mum + |= a=* + |^ (trim ?@(a a (mix $(a -.a) (mix 0x7fff.ffff $(a +.a))))) + ++ spec :: standard murmur3 + |= [syd=@ key=@] + ?> (lte (met 5 syd) 1) + =+ ^= row + |= [a=@ b=@] + (con (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) + =+ mow=|=([a=@ b=@] (end 5 1 (mul a b))) + =+ len=(met 5 key) + =- =. goc (mix goc len) + =. goc (mix goc (rsh 4 1 goc)) + =. goc (mow goc 0x85eb.ca6b) + =. goc (mix goc (rsh 0 13 goc)) + =. goc (mow goc 0xc2b2.ae35) + (mix goc (rsh 4 1 goc)) + ^= goc + =+ [inx=0 goc=syd] + |- ^- @ + ?: =(inx len) goc + =+ kop=(cut 5 [inx 1] key) + =. kop (mow kop 0xcc9e.2d51) + =. kop (row 15 kop) + =. kop (mow kop 0x1b87.3593) + =. goc (mix kop goc) + =. goc (row 13 goc) + =. goc (end 5 1 (add 0xe654.6b64 (mul 5 goc))) + $(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 From e63f332aaf59727623c5f0d951826b1878c7339e Mon Sep 17 00:00:00 2001 From: johncburnham Date: Tue, 2 Sep 2014 17:12:38 -0700 Subject: [PATCH 4/5] hoon.hoon cleanup part 1 --- arvo/hoon.hoon | 268 +++++++++++++++++++++---------------------------- 1 file changed, 116 insertions(+), 152 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index fe5769a02..d072dc191 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -50,14 +50,8 @@ [ven=term pro=term kel=@] :: vendor and product [ven=term pro=term ver=@ kel=@] :: all of the above == :: -++ claw $% [%ash p=twig] :: XX not used - [%elm p=twig] :: - [%oak ~] :: - [%yew p=(map term claw)] :: - == :: ++ clue ,[p=axis q=chum r=tyre] :: battery definition -++ coat ,[p=path q=vase] :: -++ coil $: p=?(%gold %iron %lead %zinc) :: +++ coil $: p=?(%gold %iron %lead %zinc) :: core type q=type :: r=[p=?(~ ^) q=(map term foot)] :: == :: @@ -71,7 +65,7 @@ ++ dram $% [| p=(map ,@tas dram)] :: simple unix dir [& p=@ud q=@] :: == :: -++ each |*([a=$+(* *) b=$+(* *)] $%([& p=a] [| p=b])) :: +++ each |*([a=$+(* *) b=$+(* *)] $%([& p=a] [| p=b])) :: either a or b ++ edge ,[p=hair q=(unit ,[p=* q=nail])] :: parsing output ++ foot $% [%ash p=twig] :: dry arm, geometric [%elm p=twig] :: wet arm, generic @@ -79,13 +73,6 @@ [%yew p=(map term foot)] :: XX not used == :: ++ gate $+(* *) :: general gate -++ gear |* a=_,* :: XX list generator - $_ :: - =| b=* :: - |? :: - ?@ b :: - ~ :: - [i=(a -.b) t=^?(..$(b +.b))] :: ++ hair ,[p=@ud q=@ud] :: parsing trace ++ hapt (list ,@ta) :: XX not used ++ like |* a=_,* :: generic edge @@ -141,7 +128,7 @@ == :: ++ qual |* [a=$+(* *) b=$+(* *) c=$+(* *) d=$+(* *)] :: just a quadruple ,[p=a q=b r=c s=d] :: -:: + :: XX move to zuse ++ rege $| ?(%dote %ende %sart %empt %boun %bout) :: parsed regex $% [%lite p=char] :: literal [%pair p=rege q=rege] :: ordering @@ -164,9 +151,15 @@ ++ spot ,[p=path q=pint] :: range in file ++ tang (list tank) :: general error ++ tank $% [%leaf p=tape] :: printing formats - [%palm p=[p=tape q=tape r=tape s=tape] q=(list tank)] - [%rose p=[p=tape q=tape r=tape] q=(list tank)] - == :: + $: %palm :: + p=[p=tape q=tape r=tape s=tape] :: + q=(list tank) :: + == :: + $: %rose :: + p=[p=tape q=tape r=tape] :: + q=(list tank) :: + == :: + == ++ tape (list char) :: like a string ++ term ,@tas :: Hoon ASCII subset ++ tiki :: test case @@ -204,13 +197,13 @@ ++ twig $& [p=twig q=twig] :: $% :: [%$ p=axis] :: simple leg - :: :: + :: :::::: tiling [%bccb p=tile] :: bunt a tile [%bccm p=tile] :: clam a tile [%bcpt p=wing q=tile] :: whip p into q [%bctr p=tile] :: static bunt w/ ^~ [%bczp p=base] :: bunt an axil - :: :: + :: :::::: cores [%brcb p=tile q=(map term foot)] :: %gold tray, sample p [%brcn p=(map term foot)] :: %gold core, natural [%brdt p=twig] :: dry %gold trap @@ -222,7 +215,7 @@ [%brtr p=tile q=twig] :: vulcan. wet gate [%brts p=tile q=twig] :: dry %gold gate [%brwt p=twig] :: dry %lead trap - :: :: + :: :::::: tuples [%clcb p=twig q=twig] :: [q p] [%clcn p=tusk] :: [[p ~] ~] [%clfs p=twig] :: [%$ [%$ p ~] ~] @@ -232,19 +225,19 @@ [%clsg p=tusk] :: [p ~] [%cltr p=tusk] :: p as a tuple [%clzz p=tusk] :: macro - :: :: + :: :::::: invocations [%cncb p=wing q=tram] :: %=, then cast to p [%cncl p=twig q=twig] :: pull $.p w/ sample q [%cndt p=twig q=twig] :: %-(q p) [%cnhp p=twig q=tusk] :: slam p w/ sample q - [%cntr p=wing q=twig r=tram] :: + [%cntr p=wing q=twig r=tram] :: pull p.q w/ changes [%cnkt p=twig q=twig r=twig s=twig] :: slam p w/ %*(q r s) [%cnls p=twig q=twig r=twig] :: slam p w/ %*(q r) [%cnsg p=wing q=twig r=twig] :: pull p from q with r [%cnts p=wing q=tram] :: eval. p w/ q changes [%cnzy p=term] :: pulls limb p [%cnzz p=wing] :: pulls p - :: :: + :: :::::: nock [%dtkt p=twig] :: nock 11 data skyhook [%dtls p=twig] :: nock 4 increment [%dtzy p=term q=@] :: atom constant @@ -252,9 +245,9 @@ [%dttr p=twig q=twig] :: nock p w/ formula q [%dtts p=twig q=twig] :: nock 5 equality test [%dtwt p=twig] :: nock 3 cell test - :: :: - [%hxgl p=tusk] :: slam noah w/ !>:*(p) - [%hxgr p=tusk] :: slam cain w/ !>:*(p) + :: :::::: prettyprinting + [%hxgl p=tusk] :: prettyprint tape + [%hxgr p=tusk] :: prettyprint tank :: :::::: type conversion [%ktbr p=twig] :: %gold core to %iron [%ktdt p=twig q=twig] :: cast q to type (p q) @@ -278,13 +271,13 @@ [%sgts p=twig q=twig] :: avoid duplication [%sgwt p=@ud q=twig r=twig s=twig] :: hint iff q is yes [%sgzp p=twig q=twig] :: type in stacktrace - :: :: miscellaneous + :: :::::: miscellaneous [%smcl p=twig q=tusk] :: binary to n-ary [%smdt p=twig q=tusk] :: [%smdq p=(list beer)] :: assemble string [%smsg p=twig q=tusk] :: gonads [%smsm p=twig q=twig] :: make sure q is a p - :: :: compositions + :: :::::: compositions [%tsbr p=tile q=twig] :: push bunt: =+(_p q) [%tscl p=tram q=twig] :: p changes, then q [%tscn p=twig q=twig] :: XX not used @@ -305,7 +298,7 @@ [%wthz p=tiki q=tine] :: tiki %wthp [%wtcl p=twig q=twig r=twig] :: if p, then q, else r [%wtdt p=twig q=twig r=twig] :: unless, ?:(p r q) - [%wtkt p=wing q=twig r=twig] :: if p is not its bunt + [%wtkt p=wing q=twig r=twig] :: if p is a cell [%wtkz p=tiki q=twig r=twig] :: tiki %wtkt [%wtgl p=twig q=twig] :: assert |, ?:(p !! q) [%wtgr p=twig q=twig] :: assert &, ?:(p q !!) @@ -456,8 +449,7 @@ ~/ %add |= [a=@ b=@] ^- @ - ?: =(0 a) - b + ?: =(0 a) b $(a (dec a), b +(b)) :: ++ cap :: tree head @@ -478,8 +470,7 @@ ?< =(0 a) =+ b=0 |- ^- @ - ?: =(a +(b)) - b + ?: =(a +(b)) b $(b +(b)) :: ++ div :: divide @@ -490,16 +481,14 @@ ?< =(0 b) =+ c=0 |- - ?: (lth a b) - c + ?: (lth a b) c $(a (sub a b), c +(c)) :: ++ fac :: factorial ~/ %fac |= a=@ ^- @ - ?: =(0 a) - 1 + ?: =(0 a) 1 (mul a $(a (dec a))) :: ++ gte :: greater-equal @@ -523,7 +512,12 @@ ~/ %lth |= [a=@ b=@] ^- ? - &(!=(a b) |-(|(=(0 a) &(!=(0 b) $(a (dec a), b (dec b)))))) + ?& !=(a b) + |- + ?| =(0 a) + ?& !=(0 b) + $(a (dec a), b (dec b)) + == == == :: ++ mas :: tree body ~/ %mas @@ -540,16 +534,14 @@ ~/ %max |= [a=@ b=@] ^- @ - ?: (gth a b) - a + ?: (gth a b) a b :: ++ min :: minimum ~/ %min |= [a=@ b=@] ^- @ - ?: (lth a b) - a + ?: (lth a b) a b :: ++ mod :: remainder @@ -565,8 +557,7 @@ ^- @ =+ c=0 |- - ?: =(0 a) - c + ?: =(0 a) c $(a (dec a), c (add b c)) :: ++ peg :: tree connect @@ -585,8 +576,7 @@ |= [a=@ b=@] ~| %subtract-underflow ^- @ - ?: =(0 b) - a + ?: =(0 b) a $(a (dec a), b (dec b)) :::::::::::::::::::::::::::::::::::::::::::::::::::::: :: :::: chapter 2b, basic containers :::: @@ -595,14 +585,12 @@ :: ++ biff :: apply |* [a=(unit) b=$+(* (unit))] - ?~ a - ~ + ?~ a ~ (b u.a) :: ++ bind :: argue |* [a=(unit) b=gate] - ?~ a - ~ + ?~ a ~ [~ u=(b u.a)] :: ++ bond :: replace @@ -619,16 +607,13 @@ :: ++ clap :: combine |* [a=(unit) b=(unit) c=_|=(^ +<-)] - ?~ a - b - ?~ b - a + ?~ a b + ?~ b a [~ u=(c u.a u.b)] :: ++ drop :: enlist |* a=(unit) - ?~ a - ~ + ?~ a ~ [i=u.a t=~] :: ++ fall :: default @@ -642,16 +627,13 @@ :: ++ mate :: choose |* [a=(unit) b=(unit)] - ?~ b - a - ?~ a - b + ?~ b a + ?~ a b ?.(=(u.a u.b) ~|('mate' !!) a) :: ++ need :: demand |* a=(unit) - ?~ a - !! + ?~ a !! u.a :: ++ some :: lift (pure) @@ -667,8 +649,7 @@ ^+ a =+ b=`_a`~ |- - ?~ a - b + ?~ a b $(a t.a, b [i.a b]) :: ++ homo :: homogenize @@ -691,17 +672,16 @@ ^- @ =+ b=0 |- - ?~(a b $(a t.a, b +(b))) + ?~ a b + $(a t.a, b +(b)) :: ++ levy ~/ %levy :: all of |* [a=(list) b=_|=(p=* .?(p))] |- ^- ? - ?~ a - & - ?: (b i.a) - $(a t.a) - | + ?~ a & + ?. (b i.a) | + $(a t.a) :: ++ lien :: some of ~/ %lien @@ -714,8 +694,7 @@ ++ murn :: maybe transform |* [a=(list) b=$+(* (unit))] |- - ?~ a - ~ + ?~ a ~ =+ c=(b i.a) ?~ c $(a t.a) @@ -725,8 +704,7 @@ |* [a=@ b=*] =| c=(list) |- ^- (list) - ?: =(a 0) - c + ?: =(a 0) c $(c [b c], a (dec a)) :: ++ reel :: right fold @@ -757,8 +735,7 @@ |* [a=(list) b=_|=(p=* .?(p))] |- ^+ a - ?~ a - ~ + ?~ a ~ ?:((b i.a) [i.a $(a t.a)] $(a t.a)) :: ++ skip :: except @@ -766,26 +743,22 @@ |* [a=(list) b=_|=(p=* .?(p))] |- ^+ a - ?~ a - ~ + ?~ a ~ ?:((b i.a) $(a t.a) [i.a $(a t.a)]) :: ++ scag :: prefix ~/ %scag |* [a=@ b=(list)] |- ^+ b - ?: |(?=(~ b) =(0 a)) - ~ + ?: |(?=(~ b) =(0 a)) ~ [i.b $(b t.b, a (dec a))] :: ++ slag :: suffix ~/ %slag |* [a=@ b=(list)] |- ^+ b - ?: =(0 a) - b - ?~ b - ~ + ?: =(0 a) b + ?~ b ~ $(b t.b, a (dec a)) :: ++ snag :: index @@ -794,8 +767,7 @@ |- ?~ b ~|('snag-fail' !!) - ?: =(0 a) - i.b + ?: =(0 a) i.b $(b t.b, a (dec a)) :: ++ sort :: quicksort @@ -817,8 +789,7 @@ ~/ %turn |* [a=(list) b=_,*] |- - ?~ a - ~ + ?~ a ~ [i=(b i.a) t=$(a t.a)] :: ++ weld :: concatenate @@ -862,8 +833,7 @@ ~/ %bex |= a=@ ^- @ - ?: =(0 a) - 1 + ?: =(0 a) 1 (mul 2 $(a (dec a))) :: ++ xeb :: binary logarithm @@ -876,8 +846,7 @@ ~/ %can |= [a=bloq b=(list ,[p=@ q=@])] ^- @ - ?~ b - 0 + ?~ b 0 (mix (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b))) :: ++ cat :: concatenate @@ -915,16 +884,14 @@ ^- @ =+ c=0 |- - ?: =(0 b) - c + ?: =(0 b) c $(b (rsh a 1 b), c +(c)) :: ++ rap :: assemble nonzero ~/ %rap |= [a=bloq b=(list ,@)] ^- @ - ?~ b - 0 + ?~ b 0 (cat a i.b $(b t.b)) :: ++ rep :: assemble single @@ -933,16 +900,14 @@ ^- @ =+ c=0 |- - ?~ b - 0 + ?~ b 0 (con (lsh a c (end a 1 i.b)) $(c +(c), b t.b)) :: ++ rip :: disassemble ~/ %rip |= [a=bloq b=@] ^- (list ,@) - ?: =(0 b) - ~ + ?: =(0 b) ~ [(end a 1 b) $(b (rsh a 1 b))] :: ++ rsh :: right-shift @@ -960,13 +925,16 @@ |= [a=@ b=@] =+ [c=0 d=0] |- ^- @ - ?: ?&(=(0 a) =(0 b)) - d + ?: ?&(=(0 a) =(0 b)) d %= $ a (rsh 0 1 a) b (rsh 0 1 b) 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 @@ -974,13 +942,16 @@ |= [a=@ b=@] =| [c=@ d=@] |- ^- @ - ?: ?|(=(0 a) =(0 b)) - d + ?: ?|(=(0 a) =(0 b)) d %= $ a (rsh 0 1 a) b (rsh 0 1 b) 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 @@ -989,8 +960,7 @@ ^- @ =+ [c=0 d=0] |- - ?: ?&(=(0 a) =(0 b)) - d + ?: ?&(=(0 a) =(0 b)) d %= $ a (rsh 0 1 a) b (rsh 0 1 b) @@ -1008,16 +978,13 @@ ~/ %aor |= [a=* b=*] ^- ? - ?: =(a b) - & + ?: =(a b) & ?. ?=(@ a) - ?. ?=(@ b) - ?: =(-.a -.b) - $(a +.a, b +.b) - $(a -.a, b -.b) - | - ?. ?=(@ b) - & + ?: ?=(@ b) | + ?: =(-.a -.b) + $(a +.a, b +.b) + $(a -.a, b -.b) + ?. ?=(@ b) & |- =+ [c=(end 3 1 a) d=(end 3 1 b)] ?: =(c d) @@ -1028,16 +995,13 @@ ~/ %dor |= [a=* b=*] ^- ? - ?: =(a b) - & + ?: =(a b) & ?. ?=(@ a) - ?. ?=(@ b) - ?: =(-.a -.b) - $(a +.a, b +.b) - $(a -.a, b -.b) - | - ?. ?=(@ b) - & + ?: ?=(@ b) | + ?: =(-.a -.b) + $(a +.a, b +.b) + $(a -.a, b -.b) + ?. ?=(@ b) & (lth a b) :: ++ gor :: g-order @@ -1054,11 +1018,9 @@ |= [a=* b=*] ^- ? ?: ?=(@ a) - ?: ?=(@ b) - (gor a b) - & - ?: ?=(@ b) - | + ?. ?=(@ b) & + (gor a b) + ?: ?=(@ b) | ?: =(-.a -.b) (gor +.a +.b) (gor -.a -.b) @@ -1081,7 +1043,9 @@ ?> (lte (met 5 syd) 1) =+ ^= row |= [a=@ b=@] - (con (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) + %+ con + (end 5 1 (lsh 0 a b)) + (rsh 0 (sub 32 a) b) =+ mow=|=([a=@ b=@] (end 5 1 (mul a b))) =+ len=(met 5 key) =- =. goc (mix goc len) @@ -1128,24 +1092,24 @@ :: ++ po ~/ %po - =+ :- ^= sis - 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\ - /rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\ - /holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\ - /losdilforpilramtirwintadbicdifrocwidbisdasmidlop\ - /rilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\ - /ritpodmottamtolsavposnapnopsomfinfonbanporworsip\ - /ronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\ - /sivtagpadsaldivdactansidfabtarmonranniswolmispal\ - /lasdismaprabtobrollatlonnodnavfignomnibpagsopral\ - /bilhaddocridmocpacravripfaltodtiltinhapmicfanpat\ - /taclabmogsimsonpinlomrictapfirhasbosbatpochactid\ - /havsaplindibhosdabbitbarracparloddosbortochilmac\ - /tomdigfilfasmithobharmighinradmashalraglagfadtop\ - /mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\ - /nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\ - /laptalpitnambonrostonfodponsovnocsorlavmatmipfap' - ^= dex + =+ :- ^= sis :: prefix syllables + 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\ + /rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\ + /holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\ + /losdilforpilramtirwintadbicdifrocwidbisdasmidlop\ + /rilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\ + /ritpodmottamtolsavposnapnopsomfinfonbanporworsip\ + /ronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\ + /sivtagpadsaldivdactansidfabtarmonranniswolmispal\ + /lasdismaprabtobrollatlonnodnavfignomnibpagsopral\ + /bilhaddocridmocpacravripfaltodtiltinhapmicfanpat\ + /taclabmogsimsonpinlomrictapfirhasbosbatpochactid\ + /havsaplindibhosdabbitbarracparloddosbortochilmac\ + /tomdigfilfasmithobharmighinradmashalraglagfadtop\ + /mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\ + /nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\ + /laptalpitnambonrostonfodponsovnocsorlavmatmipfap' + ^= dex :: suffix syllables 'zodnecbudwessevpersutletfulpensytdurwepserwylsun\ /rypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\ /lunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\ From 8d7ecb1f5b2d4d13d19166dccd900e3b375037b7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 3 Sep 2014 01:37:24 +0000 Subject: [PATCH 5/5] updated %clay doc --- main/pub/fab/site/styles.css | 2 +- main/pub/src/doc/ref/vol/4c.md | 341 ++++++++++++++++++++++++++++++++- 2 files changed, 339 insertions(+), 4 deletions(-) diff --git a/main/pub/fab/site/styles.css b/main/pub/fab/site/styles.css index dedf19c5e..c02e5f460 100644 --- a/main/pub/fab/site/styles.css +++ b/main/pub/fab/site/styles.css @@ -139,7 +139,7 @@ pre, .codeblock { margin-top: 0; margin-bottom: 1rem; padding: 1rem; - font-size: .9rem; + font-size: .8rem; line-height: 1.4; white-space: pre; white-space: pre-wrap; diff --git a/main/pub/src/doc/ref/vol/4c.md b/main/pub/src/doc/ref/vol/4c.md index 97d08ab7e..8dc50518e 100644 --- a/main/pub/src/doc/ref/vol/4c.md +++ b/main/pub/src/doc/ref/vol/4c.md @@ -157,7 +157,7 @@ not a `%da` for now. `%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 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 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. @@ -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 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 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 --------- @@ -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 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. + +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`)