1. 20 Jul, 2019 4 commits
    • Eric Myhre's avatar
      25702f19
    • Eric Myhre's avatar
      Ok, I have learned a hard lesson about embedding. · f6e469ce
      Eric Myhre authored
      Fields in these structs are now named.  Embedding is reserved for
      things that are very explicitly supposed to carry their methods along.
      
      At some earlier point, I embedded the Type field in some of the
      generate structs because it saved me a few keystrokes in refactoring
      template strings.  This was not important.
      
      Today I learned: if you have embeddings which cause a name to be
      shadowed -- as the generateKindedRejections_String.Type field
      could shadow the generateKindString.Type field, for example -- if those
      resolve "neutrally" (I don't know if there's a better technical term
      for this), then... in that case, the templating system will be like
      "yeah, fine, whatev", and it works.  If you give one of those two
      fields a *separate type*, the templating system will now reject it as
      if no field of that name can be found.
      
      I encountered this while working on the generator for structs (which I
      *swear* I will commit any second now, when I stop finding prerequisite
      yaks to shave -- there have been many) and trying to use a more
      specialized TypeStruct instead of the Type interface.  Whee.
      
      I get the logic of this.  The error message could be better.
      
      Anyway: even though it technically didn't affect generateString (yet),
      making the change here for consistency with what's to come
      (including specializing the field even though there's currently no
      actual need for it).
      f6e469ce
    • Eric Myhre's avatar
      Extract some error path generation. · 83bbe5e1
      Eric Myhre authored
      This isn't a net negative size diff yet, but it certainly will have
      that effect momentarily when we add a generator for another kind.
      More importantly, it reduces the set of functions in the real
      generator file to *just* the relevant ones.
      
      We'll almost certainly extend this to cover the NodeBuilder half of
      things as well, later; I just haven't gotten there yet.
      83bbe5e1
    • Eric Myhre's avatar
      Add a schema.Kind.ActsLike() ReprKind mapping. · 41465bdd
      Eric Myhre authored
      I wanted this for use in codegen work: in particular, as part of
      generating error messages.
      
      Note the comment on the case for unions.  I still go back and forth on
      this topic; see some recent previous commit messages on this branch.
      (I think I'm slowing coming around to "unions act like maps", and it's
      just that most library code chooses to jump over them transparently,
      because that's the least-odd path for resolving NodeBuilder questions;
      but it remains the case that none of this is settled for sure yet.)
      41465bdd
  2. 15 Jul, 2019 6 commits
    • Eric Myhre's avatar
      Track some important design information as tests. · 8c630e8a
      Eric Myhre authored
      The Go Playground is also often a perfectly good home for these things;
      I've also used "_rsrch" directories in other projects, especially if
      benchmarks of nontrivial runtime and setup get involved; but this
      will suffice for this quick factcheck here and now.
      8c630e8a
    • Eric Myhre's avatar
      Cut gordian knot. · ff43f7af
      Eric Myhre authored
      I'm solving the decorum problem by making "temporary" builder methods for the
      schema.Type values as necessary.  This will allow the gengo package to use
      them freely for now.  When we're done with all this, I want to restrict building
      of schema.Type values to a single method in the schema package which takes the
      "ast" types -- the ones we're hoping to codegen (!) -- and do lots of checks
      and cross-linking; the temporary builder methods will do *none*, and *of course*
      they can't take the "ast" types yet since they don't exist yet.
      
      Boom, cycle broken.
      
      Also: fix generateStringKind from taking a TypeName redundantly.
      ff43f7af
    • Eric Myhre's avatar
      3fde1f4c
    • Eric Myhre's avatar
      Add schema.Kind and Type.Kind(). Remove Type.ReprKind(). · dc442aca
      Eric Myhre authored
      The schema.Type objects don't have a `Kind() ReprKind` method.  That
      was just a bad idea.  I didn't try to fix it; I just nuked it.
      
      The new schema.Type.Kind() method docs include a description of why
      it's incorrect to wish for a either a single or a statically known
      ReprKind for a type.
      
      (Context mention: the previous commit was also a wind-up for this.
      And technically, I'm still winding back up the mental stack here:
      this had to get straightened out because I wanted to start poking
      codegen for structs; and then I had beef with the TypeStruct.tupleStyle
      field being a bool; and then fixing that pointed out that the current
      Type.ReprKind methods were kinda insane... yaks!)
      dc442aca
    • Eric Myhre's avatar
      Drop code of an incorrect attempt at Validate(). · d912ea30
      Eric Myhre authored
      Comments added addressing some of the root issues of why, and how to
      try again more correctly next time.  (At least one open question
      has been found that might take a few days to resolve.)
      
      This commit happens now because they code being removed refered to
      `schema.Type.ReprKind()` a lot, and that's the real issue I'm focused
      on at the moment -- that's also going away in the next commit or so.
      There's significantly more subtlety to the type-vs-representation
      duality than the existence of such a method could accurately describe.
      d912ea30
    • Eric Myhre's avatar
      Legacy reference fix in docs string. · ecfee940
      Eric Myhre authored
      ecfee940
  3. 13 Jul, 2019 1 commit
    • Eric Myhre's avatar
      Move minima/thunks to own file in gen. · fbc10cb8
      Eric Myhre authored
      This was triggered by an experiment about generating even more 'minima'
      like this, such as a batch of helper structs which would hold all the
      common "no, you can't do operation X on something of kind Y" methods.
      However, that diff isn't here; and is probably going to turn out to be
      abandoned, because after trying it out, I found that it was pretty hard
      to do good error messages (which... was pretty central to the point)
      with that approach.  So, more on those attempts later.
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      fbc10cb8
  4. 10 Jul, 2019 7 commits
  5. 01 Jul, 2019 2 commits
    • Eric Myhre's avatar
      Drop what remains of typed/declaration. · 231d4e87
      Eric Myhre authored
      What was left in this last file was mostly docs; and while some of
      that text might be good, we can either write it fresh or come
      dredge it out of history when we re-build something like this package.
      
      Fix the few remaining references to declaration by switching them
      to refer to the reified equivalents in the schema package (which is
      what all those references should have been anyway).
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      231d4e87
    • Eric Myhre's avatar
      Move typed/gen -> schema/gen/go. · 3c5d00d4
      Eric Myhre authored
      Dropped older PoC/draft codegen code at the same time; that
      was a stale idea and the draft that followed it is already
      clearly shaping up better.
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      3c5d00d4
  6. 25 Jun, 2019 1 commit
    • Eric Myhre's avatar
      Refactor of type/schema code. · 122c5338
      Eric Myhre authored
      - `typed.Node` -> now lives in the `impl/typed` package, more like
      other nodes.
      
      - Most of the other essential parts of reasoning about types moved
      to `schema` package.  ("typed.Type" seemed like a nasty stutter.)
      
      - `typed.Universe` renamed to `schema.TypeSystem`.
      
      - Current `Validate` method moved to `schema` package, but see new
      comments about potential future homes of that code, and its
      aspirational relationship to `typed.Node`.
      
      Conspicuously *not* yet refactored or moved in this comment:
      
      - The `typed/declaration` package -- though it will shortly be scrapped
      and later reappear as `schema/ast`.  The dream is that it would be
      neatest of all if we could generate it by codegen; but we'll see.
      (This would seem to imply we'll have to make sufficient exported
      methods for creating the `schema.Type` values... while we also want
      to make those immutable.  We'll... see.)
      
      - The `typed/gen` package is also untouched in this commit, but
      should similarly move shortly.  The codegen really ought to be built
      against the `schema.Type` reified interfaces.
      
      Overall, this drops the sheer nesting depths of packages a fair bit,
      which seems likely to be a good smell.
      122c5338