Category: Programming

  • A Gcc Frontend

    When writing the gccgo frontend I had to figure out how to write a new gcc frontend. This is a largely undocumented procedure. Unfortunately, I did not take notes as I went along. However, here are some retrospective comments. Every gcc frontend needs a set of language hooks. This is done by including “langhooks-def.h” and…

  • Go New/Make

    One of the aspects of Go that some people find confusing is the two predeclared functions, new and make. Both functions are specially implemented in the compiler. They take a type as an argument and return a value. This can make it seem confusing when you should use one and when you should use the…

  • Go Interface Values

    While interface values in Go are flexible, they do have confusing aspects. An interface value—e.g., a variable of an interface type— holds a value of some other type. The interface type is known as the static type, since that is the type that the compiler sees at compile type. The other type, which is only…

  • Go Interfaces

    One of the interesting aspects of the Go language is interface objects. In Go, the word interface is overloaded to mean several different things. Every type has an interface, which is the set of methods defined for that type. This bit of code defines a struct type S with one field, and defines two methods…

  • Go Channels

    Since the first thing I liked about Go is channels, I’ll talk some more about them. IA channel can transmit a value of a specific type. That is, a channel value of type chan T can transmit any value of type T. This is not much of a restriction, as the type interface {} can…