Disk Clock 1.4: rescue mission

Disk Clock latest 1.4. Jumped back to the last branch before I got off on the parsing tangent. Fixed the Chrome problem in DC-latest, implemented the time-unit dsl, and cherry-picked a few bug fixes to the debug logging system made on the parsing branch.

A Fork in the Road

So far Mercurial has risen to every task I’ve put before it. I exported the DC history, removed and edited the ones with the big fancy parser, and imported them into a new repository set up for that purpose.

Meanwhile, I jumped back to the last version of Disk Clock before those changes, and cherry-picked some small bug fixes to the debug module I had made in the previous branch. Mercurial calls the operation transplant, which is mildly alarming because it does an immediate commit. You can rollback a single commit, and I suppose just jump back down an earlier revision if something goes really wrong.

Don’t get idea that I spent all weekend on this – Saturday was a martial arts seminar. The functional changes were implemented two weeks ago; the repository reorg, with learning curve, took an hour or two Sunday morning.

Time Unit DSL

Now that there is actually an implementation that an enterprising hacker could play with, I ought to describe what the time unit domain specific language actually does. It lets me say things like ‘ms/day’, ‘seconds/year’, or ‘-70 days/years’.

’1′ is assumed if no other number is given; what’s really going is that units are represented internally in milliseconds, so you could say something like ’10 minutes’ and it would be perfectly appropriate to use with javascript’s timeout function, for instance. Juxtaposition like ’10′ with ‘minutes’ is multiplication; slash is read ‘per’ and is effectively transposed division.

It’s worked out fairly well. A couple of case made me have to think about it a bit, and the really wonderful thing is that finding a legal expression that made sense clarifies the understanding of the concept. For instance, the UNIX doomsday disk counts the number of seconds that fit in a 32-bit signed value. Before the DSL, I used “Math.pow(2,31) / (S_M * M_H * H_D * D_SY)” The literal translation of this to the dsl is something like ‘(seconds/year)/2^31′ (I implemented exponents just for this) which isn’t very enlightening. After thinking about it for a while and shuffling things around, I arrived at ‘years/(2^31 seconds)’ which is actually an accurate description of what the disk is showing.

Posted Sunday, September 28th, 2008 under Devlog.

Comments are closed.