Implementing Metadata in Cloje

This week I’ve been doing planning for Cloje, and trying to figure out how I might approach implementing certain Clojure features. Even if I’m not going to write the code for several weeks, I want to avoid painting myself into a corner.

One such feature is support for metadata. I see three potential approaches one might take when implementing metadata:

  • Wrap the object with a metadata container
  • Inject metadata into the object
  • Store the metadata separately from the object

Each of these solutions is pretty hairy, and there are significant trade-offs involved. So, I wrote this blog post to explore these approaches and hopefully help me decide which to use. Continue reading Implementing Metadata in Cloje

Announcing Cloje

Cloje icon Over the past couple months, I’ve been tinkering with a new side project: Cloje, a clone of Clojure built atop Scheme/Lisp.

Cloje is partly a fun learning exercise, but it may also be of practical interest to any Schemers/Lispers out there who have wished some of the cool features from Clojure were available in their language of choice.

Cloje currently targets CHICKEN and Racket, two popular implementations of Scheme. One of the chief goals of Cloje is portability. Most of the code is written using standard R5RS and SRFI features, so it would not be very difficult to add support for more Scheme implementations. I will be happy to add Common Lisp as a target, if a Lisper volunteers to help write and maintain it.

Today I tagged version 0.1 of Cloje. This is more of a “milestone” than it is a “release”. If you want to play around with it, you can clone the repository. Installation and usage instructions are available in the README. Future releases of Cloje will be available on each host language’s package manager for easy installation.

Version 0.1 of Cloje includes about 160 functions and macros. Most are reimplementations of basic Clojure features, plus some Java-look-alike functions, and a few additions to fill in some gaps. [Update (May 4): I should mention that Cloje was written from scratch by myself, guided only by Clojure’s public documentation and observable run-time behavior. None of Clojure’s source code was copied, studied, or consulted at any point in the creation of Cloje.]

Tentative plans for Cloje 0.2 include:

  • Syntax for maps, vectors, sets, regexps, and more (optional, pick-and-choose which to enable)
  • Hash-set data structures
  • Lazy sequences
  • Implementing the last few clojure.string functions
  • Various higher-order functions, map-related functions, and memoization
  • Packaging scripts, so Cloje can be made available on each host language’s package manager

Also in Cloje 0.2, I will be changing the primary goal of Cloje. I initially intended to faithfully emulate Clojure’s behavior, with the goal that existing pure Clojure code would run on Cloje. The experience of developing Cloje 0.1 has convinced me that this is not a practical or desirable goal. I’m writing a post with more about this, but for now you can read about the change of goal in Cloje’s goals document. [Update (May 9): The aforementioned post has been published.]

That’s all for now. If you play around with Cloje, let me know what you think!