Matt's Blog: while { coding }
    Back to Matt's Homepage   |   Hire Matt

A Data Structure Runs Through It

I’m surprised to be developing a programming language. I didn’t know I had a language in me until a few years ago. I always considered new languages kind of a waste. Most of the cool tricks seem to be known. No reason they can’t be added to existing languages, right?

The past few years of wide-ranging language interest have cast doubt on that perspective. Still, one theme that I can’t shake is that you should be able to model new features in an existing language. It might be awkward, but it should still be possible. (Especially if you’re going to implement the language!)

In that spirit, I’ve tried to express one of the core ideas in Wheeler with a library for Python called AssociativeTools. The star of the show is the Workspace class, which represents a data structure I call an Associative Network.

The word “network” is overloaded. Most often it is used to refer to computer networks. Here, I’m referring to a network or web of data. Think of a big pool of data in which nodes can be arranged into graphs of your choosing.

The Workspace lets you relate items (anything that is hashable in Python) to one another. Mostly I’m using strings and numbers. You relate items to build graphs so that later you can come back and fetch those graphs with partial information. It’s a lot like querying a database. It’s more like querying a search engine. Look:


s = Workspace()
s.associate("foo", "bar", "baz")
# Later in the code...
print(s.comprehend("foo"))

Outputs:

set(['bar', 'baz'])

Btw, the naming for all of this (AssociativeNetwork, associate, comprehend) is all flexible. Suggestions are welcome.