The Urn Logo

Version 0.2.7 release

It’s been a while since the last update - sorry about that. However, work on Urn has continued, resulting in some significant improvements to various parts. So then, let’s dive in to the major changes.

Compiler Plugins

One cool little feature we’ve added is the ability to register custom optimisation and warning passes with the compiler. The primary purpose of this is library-specific optimisation and warnings: for instance, you could reduce (reverse (reverse x)) to x, (assuming the list is not subsequently modified). We’ve got plans to add several builtin plugins, such as basic type checking, but that will come at a later date.

Code-gen improvements

One of Urn’s biggest failings right now is that it doesn’t generate very readable or idiomatic Lua. Whilst we are never going to be perfect, this release has seen several improvements in the emitting of conditionals. For instance, 4 line if statements are now reduced to a single line and or or.

We’ve also extended the cases where directly-called-lambdas are inlined. Before it would only inline functions which were called with constant terms. Now we will inline any time we can guarantee the execution order of expressions will not be changed. For instance:

local msg3 = _2e2e_2("Expected ", arg12["var"], " after --", key6, ", got ", (function(xs15, idx5)
  return xs15[idx5]
end)(args3, idx3))

would not have been inlined before as idx3 is rebound elsewhere. Thanks to this optimisation, we now emit:

local msg3 = _2e2e_2("Expected ", arg11["var"], " after --", key6, ", got ", args3[idx2])

as expected. This has halved the number of directly-called-lambdas in the code base.

Over all, the code gen improvements have resulted in a 600 line reduction in the compiled compiler. Other files have seen similar reductions (urn/traceback went from 246 lines to 212).