The Urn Logo

Version 0.2.9 released and a new collections library

It’s update time! Now with even more meta-programming.

Querying variables at compile time.

In addition to being able to add your own optimisation and analysis passes, we’ve also added the option to query the current context from macros and unquotes. This allows a way to dynamically query variable names, values and definitions at compile time. For instance, given:

(defun foo () (print! "Hello") 23)

we can then query foo using several methods from the compiler/resolve package.

,(with (var (var-lookup 'foo)) ;; Lookup the variable in the "active scope".
  (print! "Definition" (pretty (var-definition var))) ;; Print the variable's definition.
  (print! "Value" (pretty (var-value var))) ;; Print the variable's value
  (print! "Call" (pretty ((var-value var))))) ;; Print the result of calling the variable.

Collections 0.1

This is, as clearly evidenced by the lack of previous releases, the first release of the collections library. urn/collections is a collection (pun intended) of useful data structures and supporting architecture. While this version does not have many data structures, it does present a great leap forward in the supporting architecture area.

Namely, this release includes two much-needed critical bits of functionality, namely algebraic data types (algebraic.lisp) and lenses (lens.lisp).

Algebraic data types are a nice abstraction for presentation and decomposition of structured data, and, since they’re implemented as a relatively thin layer over lists, they are performant and compatible: namely, no modification has been needed for the standard library pattern matching system to support these ADTs.

Lenses are, basically put, purely-functional, composable getters and setters on steroids. You can use them to zoom into (pun intended, again) a bit of a data structure and potentially change it (or apply a function to it.) Additionally, there’s rudimentary support for lazy sequences, but those haven’t been integrated with either ADT or lenses.

Codegen improvements

There are also been a couple of minor optimisation and codegen improvements, fixing a couple of bugs, and reducing code size very slightly. For instance, this see these lines were reduced to a single if statement.