archives

Syntax of Literal Tables (Assocative Collections) and Auto-generated fields

In Heron I'm adding literal tables which like literal dictionaries/maps/hashes/tables in many languages (e.g. Python, Ruby, etc.) are intended to provide a convenient syntax for associative collection literals.

The syntax looks like this:

var animals = table(animal:String, sound:String, legs:Int)
  {
    "Dog", "woof", 4;
    "Cat", "meow", 4;
    "Human", "hello", 2;
  };

The first column is used as a key, and the "value" is an anonymous record containing the other columns.

So you you can say: animals["Dog"].legs.

Question one: what other languages that have built-in support associative collections with more than two columns?

Now obviously this looks a lot like a simple array of objects: but the identity is chosen as the first field. So an interesting application is to construct an object-oriented programming system built from tables alone. It would then be helpful if the first field could be an auto-generated immutable integer id (e.g. the object address, or the database auto-generated key field).

So then the question becomes what syntax should I use? I'm thinking of something like:

var animals = table(self:Id, animal:String, sound:String, legs:Int)
  {
    $, "Dog", "woof", 4;
    $, "Cat", "meow", 4;
    $, "Human", "hello", 2;
  };

Question two: I don't want to invent brand new syntax, what syntax do other languages use for similar features (auto-generated ids)?

tools to evaporate problems

(some muddling thoughts fermented with "adt vs. object" and "triz" and such.)

What problems in PLT are best solved via better tools? And what are those tools? And what does it take to get there? And which ones already exist? For example:

  • Based on my experience, the vision for Subtext rings very true: the traditional ASCII representations just don't offer enough concise information vs. a tool with layout and UI that is targeted at the narrow problem.
  • There was something useful about the Visual Age IDE's habit of breaking up files into snippets of code. I think part of the problem with the expression problem is that people are worried about what files need to be modified for a change. If our tools let us weave according to current reader need, wouldn't that free us a lot? Mightn't it help unify ADTs and Objects as well?

see history of things i started (vs. commented on)?

i'm looking for an old discussion but can't find it, i think i could better find it if i could restrict results by the name of the starter of the topic. but i don't see a way to do that?

The Theory and Calculus of Aliasing

I have done some work recently on the theory of aliasing, which I believe provides the key to the frame problem and more generally to proving O-O programs (although these applications remain to be better explained and explored further).

I was struck by the simplicity and generality of the laws uncovered in the process.

A blog entry at bertrandmeyer.com presents the basics. It includes a link to the draft paper, and also to a downloadable version of the implementation (currently a Windows executable, the source will be released later), which makes it possible to test all the examples of the paper.

-- Bertrand Meyer