The Universe of Discourse

Tue, 26 Dec 2006

Linogram development: 20061226 Update
I have made significant progress on the "arrays" feature. I recognized that it was actually three features; I have two of them implemented now. Taking the example from further down the page:

        define regular_polygon[N] closed {
point vertex[N], center;
line  edge[N];
constraints {
vertex[i] = center + radius * cis(rotation + 360*i/N);
edge[i].start = vertex[i];
edge[i].end   =  vertex[i+1];
}
}


The stuff in green is working just right; the stuff in red is not.

The following example works just fine:

        number p[3];
number q[3];
constraints {
p[i] = q[i];
q[i] = i*2;
}

What's still missing? Well, if you write
        number p[3];
number q[3];
constraints {
p[i] = q[i+1];
}


This should imply three constraints on elements of p and q:

p0 = q1
p1 = q2
p2 = q3

The third of these is defective, because there is no q3. If the figure is "closed" (which is the default) the subscripts should wrap around, turning the defective constraint into p2 = q0 instead. If the figure is declared "open", the defective constraint should simply be discarded.

The syntax for parameterized definitions (define regular_polygon[N] { ... }) is still a bit up in the air; I am now leaning toward a syntax that looks more like define regular_polygon { param index N; ... } instead.

The current work on the "arrays" feature is in the CVS repository on the branch arrays; get the version tagged tests-pass to get the most recent working version. Most of the interesting work has been on the files lib/Chunk.pm and lib/Expression.pm.