• Eric Myhre's avatar
    Introduce mixins, use for common kind features. · 1ac23897
    Eric Myhre authored
    They don't reduce line count, but they do make lines much shorter,
    and increase consistency, which are worth it.
    
    There's some very similar things already in the codegen system,
    though under a different name ("kindedRejectionHelper" something).
    I've realized the utility also exists beyond codegen.
    
    Codegen can in the future be updated to use these (and in the process,
    emit noticably fewer bytes of generated code).
    
    (There could be concerns about codegen output getting overly fragile
    and dependent on core library versions by reusing more code like this.
    However, I don't think that applies here: It's already going to be
    fragile if any of the actual error types change; being fragile if the
    mixins (which are *almost* entirely about those) change is effectively
    the same thing, it just saves a lot of output size.)
    
    I would collapse all these uninteresting methods into one line each
    rather than three lines each if I could... however, the golang
    formatter's (rather incogruous?) rule about breaking long lines in
    this *particular* case strikes.  Turns out in this corpus, for example,
    the `plainInt.LookupSegment` declaration *just* crosses over the
    length which forces a break, even though none of its siblings do.
    Sigh.
    1ac23897
mapMixin.go 2.31 KB