jeffreykegler / yahc

Yet Another Hoon Compiler
MIT License
0 stars 1 forks source link

Cell bodies with "battery body alignment" #23

Closed jeffreykegler closed 5 years ago

jeffreykegler commented 5 years ago

Below is an extract of hoon.hoon, which shows what I am calling "battery alignment" of cell bodies. We allow something similar for jogs -- instead of the tail following the head by one stop, a jogging can align its tails with each other.

But in battery cells this style is restricted to a very few places. hoon.hoon has these few, 87 occur in hood.hoon, and 278 in old-zuse.hoon.

The question: Allow battery alignment of cell bodies, as exemplified below? Or add these cases to anomaly.suppressions?

::::  4b: text processing
  ::
++  at                                                  ::  basic printing
  |_  a/@
  ++  r
    ?:  ?&  (gte (met 3 a) 2)
            |-
            ?:  =(0 a)
              &
            =+  vis=(end 3 1 a)
            ?&  ?|(=('-' vis) ?&((gte vis 'a') (lte vis 'z')))
                $(a (rsh 3 1 a))
            ==
        ==
      rtam
    ?:  (lte (met 3 a) 2)
      rud
    rux
  ::
  ++  rf    `tape`[?-(a $& '&', $| '|', * !!) ~]
  ++  rn    `tape`[?>(=(0 a) '~') ~]
  ++  rt    `tape`['\'' (weld (mesc (trip a)) `tape`['\'' ~])]
  ++  rta   rt
  ++  rtam  `tape`['%' (trip a)]
  ++  rub   `tape`['0' 'b' (rum 2 ~ |=(b/@ (add '0' b)))]
  ++  rud   (rum 10 ~ |=(b/@ (add '0' b)))
ohAitch commented 5 years ago

Hm, how many unaligned same-line arm bodies are there? I'm guessing a lot of them are naturally aligned by every single arm in the core being four(or three) letters long, though that will be less the case in newer code.

old-zuse.hoon in particular is a shim for getting old code to compile after a refactoring / guide for doing the translation, and is iirc gone in 2019 master, so if it's the main user(and there's a lot of unaligned code) probably just add these to anomalies yeah

jeffreykegler commented 5 years ago

There are 670 batteries in the arvo/ corpus, of which 302 have all their joined cells aligned at the same column. 280 do not have a defined alignment status, because all of their cells are split. And 88 are unaligned. The 88 would include batteries intended to be aligned, but with errors, which would mean an unalignment rate of 10-20%.

It might make sense to make batteries orthogonal with our treatment of joggings. There we found a battery-wide body alignment wherever possible, and treated a cell body as properly aligned if it either matched the battery-wide alignment, or was exactly one stop after the head. It's a standard that gives the writer latitude to do sensible things, but still stays fairly strict.

@ohAitch -- let me know what you think.

ohAitch commented 5 years ago

Yup that makes sense. How many of the unaligned arms are "truly ragged", i.e. at least one of the body columns is different, vs "ragged aligned", where all joined arm names are of the same length and thus the bodies are /both/ exactly one stop past and on the same column?

On Thursday, 4 April 2019, Jeffrey Kegler notifications@github.com wrote:

There are 670 batteries in the arvo/ corpus, of which 302 have all their joined cells aligned at the same column. 280 do not have a defined alignment status, because all of their cells are split. And 88 are unaligned. The 88 would include batteries intended to be aligned, but with errors, which would mean an unalignment rate of 10-20%.

It might make sense to make batteries orthogonal with our treatment of joggings. There we found a battery-wide body alignment wherever possible, and treated a cell body as properly aligned if it either matched the battery-wide alignment, or was exactly one stop after the head. It's a standard that gives the writer latitude to do sensible things, but still stays fairly strict.

@ohAitch https://github.com/ohAitch -- let me know what you think.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jeffreykegler/yahc/issues/23#issuecomment-480134924, or mute the thread https://github.com/notifications/unsubscribe-auth/ABxXhiDi3qNwBJTj7TVdIUJr50nCKuCvks5vdr_-gaJpZM4bp_kk .

jeffreykegler commented 5 years ago

As I counted it this time, all 88 of the "unaligned" were truly ragged.

On Fri, Apr 5, 2019 at 1:34 AM Anton Dyudin notifications@github.com wrote:

Yup that makes sense. How many of the unaligned arms are "truly ragged", i.e. at least one of the body columns is different, vs "ragged aligned", where all joined arm names are of the same length and thus the bodies are /both/ exactly one stop past and on the same column?

On Thursday, 4 April 2019, Jeffrey Kegler notifications@github.com wrote:

There are 670 batteries in the arvo/ corpus, of which 302 have all their joined cells aligned at the same column. 280 do not have a defined alignment status, because all of their cells are split. And 88 are unaligned. The 88 would include batteries intended to be aligned, but with errors, which would mean an unalignment rate of 10-20%.

It might make sense to make batteries orthogonal with our treatment of joggings. There we found a battery-wide body alignment wherever possible, and treated a cell body as properly aligned if it either matched the battery-wide alignment, or was exactly one stop after the head. It's a standard that gives the writer latitude to do sensible things, but still stays fairly strict.

@ohAitch https://github.com/ohAitch -- let me know what you think.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/jeffreykegler/yahc/issues/23#issuecomment-480134924 , or mute the thread < https://github.com/notifications/unsubscribe-auth/ABxXhiDi3qNwBJTj7TVdIUJr50nCKuCvks5vdr_-gaJpZM4bp_kk

.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/jeffreykegler/yahc/issues/23#issuecomment-480153790, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKmoU8aRgMrQ6i02AhII9SzCkcl2J_kks5vduBTgaJpZM4bp_kk .

jeffreykegler commented 5 years ago

Implemented battery body alignment as of commit b267979 . Will mark this "ready to be closed"

jeffreykegler commented 5 years ago

Closed as per the above.