On Sat, Aug 1, 2020 at 11:32 AM Kevin Chadwick <m8il1i...@gmail.com> wrote:
>
> On 2020-08-01 18:20, Ian Lance Taylor wrote:
> >> I'm wondering. Would it be better to have say a template in a folder that 
> >> is
> >> used to generate all the various typed Golang ready for the compiler.
> >>
> >> This way the code would be fully typed and could be maintained in one 
> >> place. The
> >> compiler could maybe still be as fast as today post generation and the 
> >> untyped
> >> code ignored and the generated typed code read more easily as standard 
> >> code?
> > There are existing tools that work that way for Go.  They can be
> > awkward for cases where you need to instantiate a type with a generic
> > type, as in List(List(int)).  They don't tend to help much with
> > compilation time overall, as each package that needs a generic type
> > needs to instantiate the template itself, so you get lots of
> > duplicates that all get compiled.  Debugging is awkward as the
> > debugger doesn't know anything about the copies.
>
> I was mainly thinking that having duplicate code with typed syntax would be 
> more
> understandable and a substantial advantage over new generic syntax that 
> requires
> further interpretation by the reader. The generated .go files could also teach
> how to write the generic code. Sounds like it may have already been considered
> and ruled out though.

Personally, when it comes to interpretation by the reader, I think
that the new generic syntax in the design draft is fairly minor.  I
don't see how a template based approach will be any clearer; it won't
be less clear, but I don't see why it will be clearer.  Perhaps you
could write down a couple of short examples to show why using
templates would be clearer for the reader.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWZPdBeN%3DrY%3DpkpopQ5U2BzYC1_kpqrCuj-3TUEGH%3Dpxg%40mail.gmail.com.

Reply via email to