Articles

How Python parses white space
One of the most distinct and remarkable things about Python's syntax is its use of white space. Python uses white space for two things: newlines are used to terminate logical lines, and changes in indentation are used to delimit blocks. Both of these behaviors are somewhat contextual.
Tagged: compilers python

Lambdas in Gypsum
I've finally added a feature to Gypsum that I've wanted for a long time: lambdas. They're useful for defining short, compact functions that can be passed to other functions as callbacks. They're especially important for functional programming (map, filter, reduce, and friends).
Tagged: compilers gypsum

Traits in Gypsum
I'm happy to announce the launch of a major new language feature in Gypsum: traits. Traits are like interfaces in Java. They provide a form of multiple inheritance. When you define a trait, you create a new type and a set of methods that go with it, some of which may be abstract. Classes and other traits that inherit from a trait will inherit those methods.
Tagged: compilers gypsum

Static and dynamic types in pattern matching
Gypsum now supports pattern matching using both static and dynamic type information. In general, pattern matching involves checking at run-time whether a value has a given type. By incorporating static type information about the value being matched, we can perform some checks that wouldn't normally be safe to perform at run-time.
Tagged: compilers gypsum

Machine learning and compiler optimization
Compilers use a heuristic function that predicts whether inlining will be beneficial. This seems like the kind of problem that machine learning was born to solve.
Tagged: compilers machine-learning v8

Type parameter bounds and variance
Type parameter bounds and variance provide a huge amount of flexibility and precision in the Gypsum type system. They let you handle many cases where you would normally have to fall back to casting and run-time type checking.
Tagged: compilers gypsum

A weird problem in the Scala type system
I've been trying to formalize the type system in Gypsum. There are two operations in particular that I want to put on a sound theoretical foundation.
Tagged: compilers gypsum scala

Gypsum now has type parameters!
Type parameters are also known as generics in other languages. They enable parametric polymorphism, providing abstraction over types for functions and classes.
Tagged: compilers gypsum

Structure of the Gypsum compiler (part 3)
In this article, I discuss closure conversion, class flattening, CodeSwitch bytecode, semantic analysis, and serialization.
Tagged: compilers gypsum

Structure of the Gypsum compiler (part 2)
In this article, I discuss the Gypsum intermediate representation, declaration analysis, inheritance analysis, and type analysis.
Tagged: compilers gypsum

Structure of the Gypsum compiler (part 1)
Gypsum is an experimental language, so the compiler is designed to be very flexible, easy to change and extend. The nice thing about side projects is that you can spend some extra time making sure the code is clean and elegant. You don't have to take on any technical debt to meet deadlines.
Tagged: compilers gypsum

The Strahler number
I was browsing Wikipedia and came across an article on the Strahler number, which measures the branching of a tree. The number originally came from hydrology and was used to describe systems of rivers and streams.
Tagged: compilers

A simple interpreter from scratch in Python (part 4)
We will build the last component of the interpreter, the evaluator, by modelling the program environment and by coding how each statement and expression should be executed.
Tagged: compilers imp python

A simple interpreter from scratch in Python (part 3)
We create an abstract syntax tree for our toy language and write a parser using our parser combinator library.
Tagged: compilers imp parsers python

A simple interpreter from scratch in Python (part 2)
In this article, we will write a small parser combinator library. The combinator library is language agnostic, so you could use it to write a parser for any language.
Tagged: compilers imp parsers python

A simple interpreter from scratch in Python (part 1)
In the first part in this series, we build the lexer, the first component of an interpreter for our toy language, IMP.
Tagged: compilers imp python

Currying and why we don't pass arguments as tuples
Tagged: compilers fenris functional-programming

Method resolution
Tagged: compilers fenris

Fixpoint type inference
Tagged: compilers fenris

Type tagging format
Tagged: compilers fenris

Limitations on generics
Tagged: compilers fenris

Type inference
Tagged: compilers fenris

Type inference and generics post-mortem
Tagged: compilers fenris