Adventure: Is there light in the cobble crawl?

The original Colossal Cave Adventure consists basically of a Fortran source file and a textual data file. These files would often travel from one installation to another via paper printouts: printed out at one site, typed in by hand at another.

The lines of WOOD0350’s Fortran source (intentionally or not) never exceed 80 columns regardless of your tab stop. But the data file fits within 80 columns only with a tab stop of four. With an eight-space tab stop, four lines of the data file exceed 80 columns:

Read More

Adventure: Walking on the ceiling

On 2012-12-01 I wrote to Don Woods (in a postscript to a production update on Colossal Cave: The Board Game):

By the way, I just noticed last week that in “Adventure”, in the Hall of the Mountain King, the directions NORTH and LEFT are synonyms, as are SOUTH and RIGHT… as are WEST and FORWARD!  West being forward makes sense, if the Hall of Mists is back to the east; but for the rest I suppose the adventurer must be walking on the ceiling. :)  This little mixup is present all the way back to Crowther’s code. I just thought it was funny that nobody had commented on it before, as far as I know.

Read More

Things C++26 define_static_array can’t do

We’ve seen previously that it’s not possible to create a constexpr global variable of container type, when that container holds a pointer to a heap allocation. It’s fine to create a global constexpr std::array, or even a std::string that uses only its SSO buffer; but you can’t create a global constexpr std::vector or std::list (unless it’s empty) because it would have to hold a pointer to a heap allocation.

Read More

The “macro overloading” idiom

Here’s a neat trick to create an “overloaded macro” in C, such that M(x) does one thing and M(x, y) does something else. For example, we could make a macro ARCTAN such that ARCTAN(v) calls atan(v) and ARCTAN(y,x) calls atan2(y,x).

#define GET_ARCTAN_MACRO(_1, _2, x, ...) x
#define ARCTAN(...) GET_ARCTAN_MACRO(__VA_ARGS__, atan2, atan)(__VA_ARGS__)
Read More

Chromium’s span-over-initializer-list success story

Previously: span should have a converting constructor from initializer_list (2021-10-03). This converting constructor was added by P2447 for C++26. Way back in 2024, Peter Kasting added the same constructor to Chromium’s base::span — he emailed me about it at the time — but I was only recently reminded that in the /r/cpp thread about the feature he’d written:

Yup, this change was so useful it led to me doing a ton of reworking of Chromium’s base::span just so I could implement it there.

Speaking of ambiguity: out of context that comment could be taken as sarcasm. What programmer enjoys “doing a ton of reworking just” to implement a single new constructor? Did he mean the change was so useful, or, like, “so useful”? :) So it’s worthwhile to track down pkasting’s actual commit from November 2024 and see all the places he sincerely did clean up as a result.

Read More

Seven Types of Ambiguity (1930)

The other week I read William Empson’s Seven Types of Ambiguity (first published 1930, third edition 1953 with new footnotes by the author). Empson purports to taxonomize all sorts of “ambiguity,” defined as any technique or nuance “which gives room for alternative reactions to the same piece of language.” Really I’m not sure I fully grasped his taxonomy. (One might call it a taxonomy of ambiguity in more ways than one!) But it’s something like this:

Read More

A dialogue on trivial-abi and trivially relocatable

I wrote in [[trivial_abi]] 101” (May 2018), during the active development of the [[clang::trivial_abi]] attribute:

Relation to trivial relocatability: None… well, some?

As you can see, there is no requirement that a [[trivial_abi]] class type should have any particular semantics for its move constructor, its destructor, or its default constructor. Any given class type will likely be trivially relocatable, simply because most class types are trivially relocatable by accident…

A correspondent writes in with a query for Socrates (previously seen on this blog in July 2023).

Epistolographos writes: Actually, I think trivial-abi-ness and trivial relocatability are almost the same thing.

Read More

KenKen with Roman numerals

The other day my wife suggested the idea of KenKen “with letters.” There’s probably an idea in there related to anagrams, somehow; but the first idea that popped into my head was to use Roman numerals. Here’s a “really Latin square” for you to solve:

Read More

Recent miscellany: 1D glider, flags, stripes, and telephony

Big news of the week, via Hacker News: Someone has engineered a 1D spaceship in Conway’s Game of Life! That is, there exists a pattern which initially fits into a bounding box of dimensions \(3\,707\,300\,605\times 1\) — that “1” is what makes it “1D” — and, when evolved for \(133\,076\,755\,768\) steps, reforms itself into exactly the same pattern shifted two cells to the left.

Read More