Articles

Bits, Bytes and More Ambiguous Syntax

Recently, I added a first-class byte type to Whiley.  Unlike Java, this is not interpreted as some kind of signed or unsigned int. That’s because I find that very confusing since a byte is really just a sequence of bits without any interpretation.

Therefore, in Whiley, a byte is just that: a bit . . . → Read More: Bits, Bytes and More Ambiguous Syntax

On the Duality of Types: the Ideals versus the Reals

I’ve been working hard over the last few weeks on the next release of Whiley, which should be out soon.  However, I’ve got myself into a little bit of a pickle over the type system (again).  I want the type system to be simple and easy to use, but at the same time efficient . . . → Read More: On the Duality of Types: the Ideals versus the Reals

Implementing Structural Types

Introduction

Over the last few months, I’ve been working on the type system underpinning Whiley.  A key feature is the use of [[Structural type system|structural typing]], rather than [[nominal typing]], and I’ve blogged about this quite a bit already (see [1][2][3][4]).  Over the weekend, I finally found time to work through all my thoughts . . . → Read More: Implementing Structural Types

Minimising Recursive Data Types

Following on from my previous post about structural subtyping with recursive types, a related problem is that of minimising recursive types. Consider this (somewhat artificial) example:

define InnerList as null | { int data, OuterList next } define OuterList as null | { int data, InnerList next } int sum(OuterList list): if list ~= . . . → Read More: Minimising Recursive Data Types

A Problem with Structural Subtyping and Recusive Types

One problem causing me a headache is how to implement [[Structural type system|structural subtyping]] for [[recursive data type|recursive types]] (which I first blogged about here). The following example illustrates the basic idea:

define Link as { int data, LinkedList next } define LinkedList as null | Link LinkedList f(Link list): return list

This is . . . → Read More: A Problem with Structural Subtyping and Recusive Types

More on Flow-Sensitive Typing

The idea behind flow-sensitive typing in Whiley is to give a statically typed language the look-and-feel of a [[Dynamic programming language|dynamically typed language]] (as much as possible).  The following illustrates:

int average([int] items): v = 0 for i in items: v = v + items[i] return v / |items|

Here, we see that there . . . → Read More: More on Flow-Sensitive Typing

On Flow-Sensitive Types in Whiley

In the ensuing months since the previous release of Whiley, I have been working away on a major rewrite of the compiler. This is now almost ready, at last! One of the “executive decisions” I made recently, was to move away from a declared variable model to a completely [[Data-flow analysis|flow-sensitive]] typing model. To . . . → Read More: On Flow-Sensitive Types in Whiley

Normalising Recursive Data Types

Recently, I came across an interesting problem with the type system I’m using in Whiley.  Specifically, the problem relates to recursive types which are equivalent but not identical.  Consider, for example, the following Whiley code:

define Link as { int data, LinkedList next } define LinkedList as null | Link

This is a fairly . . . → Read More: Normalising Recursive Data Types