Search code examples
language-agnosticprogramming-languages

What's the programming language of this code snippet?


I'm rather puzzled by this programming challenge - I don't know what language it's in (that's part of the fun, but I need some help). I'm not looking for the answer to the challenge, which is to find a bug in the code, so don't spoil it for me. I merely need to find what fine language it's in. The code challenge presupposes that there's a bug in just one line in the code, so we've got to accept everything that's on more than one line.

I've tried in vain to figure it out. I've looked at rosettacode and I can't find anything even remotely like this there. The closest it looks to is Algol 60, but it's not strictly Algol 60 as defined there. There are various issues. For one, comments start with % like in Erlang. The define is nowhere in Algol 60, neither is the odd <unsigned number> # syntax. Algol 60 also used an escape syntax for identifiers (they had a separate namespace, usually printed in bold) - that's nowhere to be seen either.

Looking at less popular things that I'm familiar with, it's not in IEC 61131-3, neither is it HAL/S.

begin

  % Speed of light in meters/second
  define c=2.99792458e8#;

  % Convert frequency in Hz to free-space wavelength in meters.
  real procedure wavelength(frequency);
    value frequency;
    real frequency;
    wavelength := c/frequency;

  real f, lambda;

  lambda := wavelength(f);
end.

Solution

  • I was fortunate enough to work with two ranges of machines which used Algol 60 heavily. Firstly the English Electric KDF9 which had several Algol 60 compilers conforming fairly closely to the language described in the Revised Algol 60 Report. Then I moved to Burroughs Machines which eventually transmogrified into Unisys. So the DEFINE statement is a feature of Unisys Extended Algol for text substitution. See page 3-90 of ALGOL Programming Reference Manual 1. I think that having to know that, in this flavour of Algol, number constants having an exponent part need to prefix this by @ rather than E is unfairly obscure!! See page 2-6 of 1.