January 2010 Archives

I saw Eternity the other night
Like a great Ring of pure and endless light
    All calm as it was bright;
And round beneath it, Time, in hours, days, years,
    Driven by the spheres.
Like a vast shadow moved, in which the world
    And all her train were hurled.
                              — From The World by Henry Vaughan
Twenty-one years after its publication in Analog, here is Marc Stiegler's story The Gentle Seduction: nanotechnology and the hours, the days, the years, and the billennia.


In most languages, to "dereference" a pointer is to treat its value as a machine address and look up the data therein. Snobol is different. Strings are one analogue of pointers. And one can go, at run-time, from a string to the variable with the same name. Or even to a label with the same name: a string computed goto.

In Arbno, the Cursor, and Snobol Patterns in Prolog, I showed how to implement Snobol pattern matching with Prolog Definite Clause Grammars (DCGs), listing the Prolog code for "any", "span", the "$" immediate-assignment operator, and two attempts at "arbno". Here is another pattern I've found useful, a "span" variant that also counts the characters matched. And I'd like to ask: what higher-order abstraction would you use to implement both this and the normal "span"?

Two Sundays ago, I walked with my friend Hendrik Hilberdink along the Oxford canal and into Kidlington. As we wandered along Kidlington's stunningly tedious main street, I pointed out the gym that I use. Oxford prices being what they are, it's cheaper than ones nearer home. But I haven't visited it recently, because I reckon I've expended enough calories letting my fingers do the walking. They've been typing recursive list decompositions and base cases in Prolog, pounding out the same old boring boilerplate code over and over and over again. In this essay, I'll show you how to eliminate the boilerplate by using higher-order programming: functions that take other functions as arguments; or in Prolog, predicates that take other predicates as arguments. I have experimented with it to share code between the "span" and "span_count" patterns that I talked about in Snobol Patterns in Prolog II: Span with Count.

Can any Prolog or SWI-Prolog expert tell me how to implement an equivalent of Snobol's "arbno" pattern for use in Definite Clause Grammars, efficiently and elegantly? This is the pattern that matches an arbitrary number of repetitions of an argument pattern. And how would you define Snobol's "$" and "@"?

There is a collection of jokes at various places on the Web, for example Susan Stepney's How to Shoot Yourself In the Foot, that invites you to compare a C program for shooting yourself in the foot with programs in other languages. The C program is straightforward; those in the other languages have extravagantly elaborate effects. Except Basic, which manages only to soak your trousers with a water pistol. I was reminded of these jokes by Christopher Yeleighton's reply What about reflexion? to my New Year's resolutions about how to choose a programming language. Christopher asked whether I would use a language where I can't determine the contents of a function at run time. I do use such languages, but that's not interesting, so I'm going to show you how I program in one where I (almost) can. It's a beautiful and wonderfully mutable language called Snobol4, which enables you to pump out new statements at run time like a sausage-maker gone berserk, except that sausages are not executable. I hope that my article will teach you enough Snobol to understand the Snobol version of the foot joke.

About this Archive

This page is an archive of entries from January 2010 listed from newest to oldest.

January 2009 is the previous archive.

February 2010 is the next archive.

Find recent content on the main index or look in the archives to find all content.