1. 7
  1.  

  2. 2

    Go doesn’t have a dispatch table, but interface values. It’s literally more of a freestyle dispatcher mechanism that requires some work during interface value assignment — it generates a tiny lookup hash-table for the concrete type it’s pointing to. The assignment is not insanely expensive, so it’s a fair exchange for a more pleasant type system. Ian Lance Taylor has a great blog post about the internals if you’re looking for further reading.

    Yes it does have a dispatch table, and the linked post says it too:

    The table of functions is stored sorted by the name of the method, although the name does not appear in the table. Calling a method on an interface means calling a specific entry in this table, where the entry to call is known at compile time. Thus the table of functions is essentially the same as a C++ virtual function table, and calling a method on an interface requires the same series of steps as calling a C++ virtual function: load the address of the virtual table, load a specific entry in the table, and call it.

    1. 3

      It’s the case of gccgo maybe not go native compiler

      1. 1

        If one wants run-time subtyping, one have no choice but to include a dispatch table.

      2. 3

        You should point it out in the Medium post so that she can correct it. I doubt she’ll see it here :).

        1. 3

          I saw it and made it clearer.

        2. 2

          The post should have said Go doesn’t have a traditional dispatch table, the ivalue mechanism I’m explaining is also dispatching. I made it more obvious.

          The point of the Go’s type system is the way it organizes the table, a method via an interface has its own entry that’s not associated with a parent type.