Hello again! Somehow imperceptibly for myself, I took a course not on abnormal programming itself, but in languages well suited for abnormal programming. Of course, you can surprise the public with another C ++ program, but I will go some other way. In the 1950s and 1970s, programming was only born and it was unclear what an ordinary programmer needed and what was dangerous. It was because at that time there was no idea what the Tru programming language should be like; such constructions and means often appeared that a modern programmer would have choked on food while studying a different manual. So forget about what you learned such masters of words like Knut and Stroustrup and go under the cut!
Liberty over the edge
PL / 1 always finds what else to throw a wild programmer. For example, the expression
9<8<7
is
true ! The logical question is why? How is such a thing possible and how have language developers allowed it ??? Well, you have to dig into the manuals. To begin with, there are no logical variables in PL / 1, zero is false, and everything else is true. Also, almost any implicit conversions are allowed, it gives about 50% more errors. Consider how the translator parses the composite logical expressions.
The first thing that catches the eye is two identical operations '>', and their priority is the same. Thus, the expression 9 <8 <7 turns into
(9<8)<7
9 <8 is a lie, so the brackets disappear and the expression changes before our eyes:
0<7
Seven is really more than zero, so the truth is returned. I will spit on C until logical variables appear there. Also, this is a sufficient justification for the fact that in most high-level languages, logical variables are simply necessary. Otherwise, such problems simply can not be avoided.
Here is one more interesting rake, about which the beginning programmers on PL / 1 often crippled their legs. We read the documentation on the PL / 1. It says that multiple assignment is allowed. Suppose we have three variables — A, B, and C.
A=5;
B=6;
C=B=A; /* , */
What do you think the variable C is equal to ??? It is not five at all, it is ... zero! Wait, but the manual says that multiple assignment is allowed, how is that? Yes, you probably already guessed - the second equal sign is a logical operation, and the multiple assignment looks like this:
C,B = A;
All problems of this kind arise from the fact that the line between logical and arithmetic operations is blurred. Reader, you are mistaken in the belief that this is the height of originality. More weird things are described below.
Pronouns in Nebula
Each variable has its own name - so we are taught from kindergarten. But in the bearded 60s, not everyone thought so. In an attempt to get closer to the real language, monsters such as Kobol or Nebula were spawned. For example, why not write
();
( );
It seems to me not to be a very natural and useful construction, but the creators of Nebula did not think so. They introduced the pronoun
QIH
into the language - a pointer to the current value. If you think that this is the height of madness, then it is better not to even read about nameless variables, but go straight to the wildness of syntax.
Unnamed variables
A person, having played enough with Nebula, quickly realizes that it would be nice to give up names altogether. POP-2 did just that. All variables are declared to VARS operators:
VARS XYZ;
Now we can write something like
X + Y -> Z;
However, no one bothers us to write just
X + Y;
Now the amount is stored on the stack, which is used implicitly. This allows you to get rid of the names of temporary variables. Some time after the X + Y command, we can write
-> Z;
The number comes from the stack and is placed in a variable. POP-2 should not be confused with languages such as Forth or Factor. The POP-2 stack is just an auxiliary tool, albeit a very useful one. The stack can store data between procedure calls, which allows you to not think about the lifetime of a variable. These and many other features of POP-2 allowed him to become a convenient tool for logical programming, but he did not receive wide popularity, it was used only in England.
')
Conditional Operators that cripple the brain
Currently, in almost all new programming languages (except Python and its derivatives, indents and tabs are used there) the if statement has two clearly limited blocks. I can write something like this on Eifile or Lois:
if a<b then
...
if c<d then
...
else
...
end
...
end
Each if has its end and I can say for sure if the else is related to if. Due to this, in the process of broadcasting the program will not raise any questions. But here is a completely admissible entry in the language PL / 1 (Please note, even before ELSE you need to put a semicolon, we'll talk more about this):
IF 9<8<7 THEN IF 9>8>7 THEN CALL AAA; ELSE CALL BBB;
The translator is legitimately wondering - what kind of IF is ELSE? Because of this ambiguity, we had to introduce a requirement that, in the nested IF, each conditional operator would have its own ELSE. Here’s how this example can be rewritten:
IF 9<8<7 THEN IF 9>8>7 THEN CALL AAA; ELSE; ELSE CALL BBB;
Now man is surprised.
In ALGOL 60, this problem is solved a little better, but also rather ugly: nested if should be in the begin ... end block:
if 9<8<7 then begin
if 9>8>7 then aaa end
else bbb;
The situation is complicated by the fact that then the programs were introduced from punched cards, because of this, people could not arrange them with beautiful indents and other benefits of progress, all programs were a bloody mess of symbols piled into a heap. There is one bright spot in this black mess - POP-2. You can close a nested loop with the close operator:
if b1 then if b2 then S1 close
else S2 close
It is much more elegant than the PL / 1 agreement. Here it is necessary to eliminate one ambiguity: there was no operator like case then. The case in Algol was essentially a refined, calculated goto. Therefore, our ancestors were forced to sculpt a lot of if in one heap.
Semicolon cancer
A long time ago, programs were introduced with punched cards. All that came to the translator is a continuous stream of characters. In such circumstances, the use of a semicolon was a real salvation. At present, this is no longer so relevant, but in the olden days they did not think so. The developers of the PL / 1 understood this too literally, so the semicolon completes everything that is possible, it climbs into all the gaps. About the fact that before the else-branch you need to put a semicolon, we have already said. But that's not all the charms of the submarine / 1! The semicolon must be set even after the DO in the DO block:
IF 9<8<7 THEN CALL ERROR; ELSE DO; A=5; B=6; END;
Early versions of the PL / 1 eaten this mess with pleasure.
Reserved words
~ 300 words cannot be used by a programmer in Kobol! On the other hand, there are no reserved words in FORTRAN or SL / 1 at all; a person is free to do whatever he pleases:
IF IF THEN THEN; ELSE ELSE;
There is nothing even to say, it is better not to take it, to spit and pass by.
Conclusion
As we see, our ancestors also knew all the subtleties of abnormal programming, often their bydlocod is more interesting than ours. Note that I did not, as usual, give references to programming languages, as there are only articles on PL / 1, Algol and Cobol in Russian Wikipedia, and the article on Cobol is very incomplete. And to find information about such nuggets as BLISS, SPL, CORAL 66 or Nebula is completely impossible. As for POP-2, I found some information, and there is even some article about POP-11, but an article. In general, these languages are long dead and no one uses them anymore. There are exceptions, this is PL / 1 and Kobol, but their hour of death is near. I found all the information in my collection of old books on computer science. In particular, translations of Barron’s books served as the main source of knowledge. If interested, look on the net,
here's the cover .