Category Archives: DimensionalMap

DimensionalMap: Moved to Sourceforge, version 1.0a2 released

What is DimensionalMap?

  • Moved DimensionalMap project to Verbosio.  The Google Code project is now obsolete and scheduled for deletion.
  • Removed Proxy / membrane code (it didn’t work entirely, it will break soon, and it just got in the way)
  • Rebased build system on my Verbosio-Jasmine repository (supports xpcshell testing, downloading XULRunner SDK)
  • Implement a .hasAny(dimensionName, coordinate) method.
  • TODO: Migrate online documentation.

Source repository at .

Insane in the membrane!

(I’ve been wanting to use this blog title for months. Insane in the brain!)

Over the last year, I’ve been experimenting with JavaScript proxies and the concept of a “membrane”. (Tom van Cutsem has a nice introductory write-up.) The idea of truly private properties in JavaScript is just so compelling…

… and such a waste of my time.

The hard truth is I’m spending so much time chasing this ideal that I forgot the API I’m working with is unstable as all hell, and sooner or later, it is going to change. Given that latter requirement, and that my planned code design now has a very fragile choke-point on it, I’m going to bite the bullet and admit that building a membrane now, when I have only pieces of the design that’s going to use it, was a pretty bad idea.

What I should’ve done – and what I will now do – is to create a stub membrane with nothing more than “forwarding handlers” between the code I’m prototyping, and the code which exercises it. Most critically, I want to turn that membrane off when I’m doing development. Later, when I need a real membrane, I’ll have a single isolated place to start with. When the API does change, it’ll be in one place to fix.

I have good weeks, and I have bad weeks. Oh, well.

When did SourceForge become so nice?

Many years ago, I tried being a developer on SourceForge. It was thoroughly unpleasant, and I couldn’t figure out how to do it.  Last night, I tried again, and oh, my goodness, was it nice:

  • An extremely friendly web interface for admins
  • Multiple repositories at the drop of a hat for one project
  • SSH was a breeze
  • OpenID support
  • A very simple bug tracking system

Mercurial’s ability to push from one repo to another hosted somewhere else made life a little easier, too, and the convert extension meant I could bring over the old CVS-based checkins pretty easily.

Considering the number of times I’ve had to restart, and the fact I’m still going it alone, this is almost perfect. I chose Google Code for DimensionalMap at the time because I was in a hurry. I chose Mozdev for Verbosio because it seemed like a good idea at the time. SourceForge beats both of them for me, for all of the above reasons.

I am a happy developer.

DimensionalMap 1.0a1 Release

DimensionalMap project and 1.0a1 Release

For the last several months, I’ve been working on a new idea.  ECMAScript Harmony introduces the concept of WeakMaps – hashtables built directly into the JavaScript language.  It’s a simple key-value hashtable.  I went a little further: key-key-key-key…-key-value.

Specifically,  I took the WeakMap API and redefined it for a multi-dimensional hashtable.  I think my Concepts wiki page has a pretty good explanation of the problem I’m trying to solve:

 Consider a HTML table:

Table 1

9 2 3
8 1 4
7 6 5

The pattern behind this table’s layout is pretty obvious to us in two dimensions: the center has 1, and as you move in a spiral, you increment the value assigned to each cell. But if you didn’t know the pattern, or were simply storing data (as this article does), how would you do it?

The typical answer is to define a two-dimensional array – more specifically, an array of arrays. This is in fact precisely what HTML does. Observe the markup for the above table:

<table border="1" style="width: 200px">
  <caption>Table 1</caption>

This long string of characters serializes a two-dimensional array as a HTML table. This works fine when I need to store only two dimensions of data. But where might I put the number 10, if in neither an adjacent row nor an adjacent column? An adjacent floor, perhaps – a third dimension?

There’s a key assumption here. The assumption is that our data structure already has all the dimensions it will need. To add another dimension, another degree of freedom, you’d have to rewrite the data structure entirely. A HTML table is clearly not capable of handling three dimensions – nor do I mean to suggest it should. Here, it’s just an example.

The DimensionalMap library is supposed to give its users the ability to store data in its space, validate the keys (coordinates) being passed in, and add new dimensions to its space.

I also wrote a quick-and-dirty mockup of the Document Object Model to test DimensionalMap against.  I found four specific uses for DimensionalMap in the mockup:

  • Supporting namespaced DOM attributes (xlink, anyone?)
  • Supporting undo and redo operations
  • Reverting all “uncommitted” changes when an exception is thrown
  • Shadow or anonymous content hidden from the mainstream DOM

This is an “alpha” release for two reasons:

  1. DimensionalMap depends on the Map and Proxy features of ECMAScript Harmony, which only Mozilla “Aurora” and Google Chrome “Dev” builds have.
  2. None of this code or documentation has been reviewed by anyone yet.  I’m posting now because it’s time to ask for those reviews.  Certainly I want to make it useful for others, not just me.

I’ve spent several months working on this, spare-time, as infrastructure for my Verbosio project.  (It’s still not dead yet!)  I chose the mockups test deliberately to see what challenges I would face in building my XML templates markup model – which I’ll be happy to explain to anyone interested, but it still doesn’t work.

Unlike other works of mine in the Mozilla community, this one is entirely web-safe, using to the best of my knowledge ECMAScript-compliant and Harmony-compliant code only.

As always, your feedback is most welcome!