Computer Things

Subscribe
Archives
  Back to the email
YawarRaza7349
November 25, 2025, morning

Actually, that ALTER statement seems fine. Notice that the "body" of paragraph-name-1 can only be a single GO statement. That means that paragraph-name-1 is effectively a name for some other GO destination. Without ALTER, it would be an alias for said destination, but with ALTER, it's instead a mutable variable that can reference an arbitrary GO destination. This can be handy for emulating what you might otherwise do with a first-class function. See the following C/JS examples:

Click to expand C code

#include <stdio.h>

int (*summand)(int);
int summate(int l, int u) {
    int sum = 0;
    for (int i = l; i <= u; ++i) {
        sum += (*summand)(i);
    }
    return sum;
}

int id(int i) { return i; }
int sqr(int i) { return i * i; }

int main() {
    summand = &id;
    printf("%d = %d\n", summate(1, 10), 11 * 10 / 2);
    summand = &sqr;
    printf("%d = %d\n", summate(1, 10), 21 * 11 * 10 / 6);
    return 0;
}
Click to expand JS code

let summand;
const summate = (l, u) => {
    let sum = 0;
    for (let i = l; i <= u; ++i) {
        sum += summand(i);
    }
    return sum;
};

const id = x => x;
const sqr = x => x * x;

summand = id;
console.log("" + summate(1, 10) + " = " + (11 * 10 / 2));
summand = sqr;
console.log("" + summate(1, 10) + " = " + (21 * 11 * 10 / 6));

In COBOL, you'd define summand as a paragraph with a "body" of a single GO statement. The above assignments to summand would then each translate to an ALTER statement in COBOL: ALTER summand TO PROCEED TO id, ALTER summand TO PROCEED TO sqr (or something like that; I don't know COBOL). Of course, that GO(TO) doesn't return means you can't as easily reuse id and sqr (they need to GO back to summate), but that sounds orthogonal to taking issue with ALTER as compared to normal GO(TO).

Reply Report
Powered by Buttondown, the easiest way to start and grow your newsletter.