
Build Your Own Programming Language
By :

The function call is the fundamental building block of both imperative and functional programming paradigms. In object-oriented languages, functions are called methods, but they can play all of the same roles that functions can. In addition to this, a set of methods provides an object's public interface. To type check a method call, both the number and the type of the parameters must be verified along with the return type.
The type representation introduced in the previous Chapter 7, Checking Base Type, included a methodtype
class that had fields for the parameters and the return type; however, we haven't yet presented the code to extract that information from the syntax tree and place it into the type. The parameters and return type of a method are called its signature. The grammar rule where a method signature is declared is the one that builds a MethodHeader node
. To calculate the return...