3 ms·
A lot of programming languages are descendants of ALGOL [1], where the ; is the separator, not a terminator (you don't have to use it on the last statement of a
by drivers99 7y ago
A lot of programming languages are descendants of ALGOL [1], where the ; is the separator, not a terminator (you don't have to use it on the last statement of a block of code).
Pascal (being based on algol) is the same, and the final "end." statement of the program, which is the main program, has a period/full stop. See end of this sample: [2] A begin / end block is one statement so they end like so "end;" unless it's the last one in a procedure, in which case you don't need the semi-colon.
C was similar, except they made ; a terminator instead of separator, but you don't have to put it at the end of being/end blocks. C just uses { } to make it clear. But then, in C++ I always forget to put ; at the end of a class definition. I get why it's there, but it looks more like a function definition to me which doesn't need a semicolon at the end.
Many languages are also from C or at least the Algol family tree (but usually C), like C++, Java, Javascript, etc.
More about ALGOL: https://en.wikipedia.org/wiki/ALGOL https://en.wikipedia.org/wiki/ALGOL
[1] Algol sample: http://sandbox.mc.edu/~bennet/cs404/doc/primes_alg.html http://sandbox.mc.edu/~bennet/cs404/doc/primes_alg.html
[2] Pascal sample: http://courses.washington.edu/css448/zander/Code/array.p http://courses.washington.edu/css448/zander/Code/array.p