INTERCAL: Difference between revisions
Jump to navigation
Jump to search
imported>IrisChronomia |
imported>Ais523 →Details: undo an old change of word quote within a quote – direct quotes should match the wording in the source, otherwise they wouldn't be direct quotes (see MOS:PMC), and the original source is not typoed either but was using an obscure word (wikt:wont) for effect (and thus shouldn't be silently corrected due to not being a typographic error) |
||
| Line 15: | Line 15: | ||
The original Princeton implementation used [[punched card]]s and the [[EBCDIC]] character set. To allow INTERCAL to run on computers using [[ASCII]], substitutions for two characters had to be made: <code>$</code> substituted for <code>¢</code> as the ''mingle'' operator, "represent[ing] the increasing cost of software in relation to hardware", and <code>?</code> was substituted for <code>⊻</code> as the unary [[exclusive-or]] operator to "correctly express the average person's reaction on first encountering exclusive-or".<ref name="manual72"/> In recent versions of C-INTERCAL, the older operators are supported as alternatives; INTERCAL programs may now be encoded in [[ASCII]], [[Latin-1]], or [[UTF-8]].<ref>{{cite web|url=http://c.intercal.org.uk/manual/atvm81sp.htm|archive-url=https://archive.today/20121224065530/http://c.intercal.org.uk/manual/atvm81sp.htm|url-status=dead|archive-date=2012-12-24|title=Princeton and Atari Syntax – C-INTERCAL 0.27 Revamped Instruction Manual|access-date=2012-11-12}}</ref> | The original Princeton implementation used [[punched card]]s and the [[EBCDIC]] character set. To allow INTERCAL to run on computers using [[ASCII]], substitutions for two characters had to be made: <code>$</code> substituted for <code>¢</code> as the ''mingle'' operator, "represent[ing] the increasing cost of software in relation to hardware", and <code>?</code> was substituted for <code>⊻</code> as the unary [[exclusive-or]] operator to "correctly express the average person's reaction on first encountering exclusive-or".<ref name="manual72"/> In recent versions of C-INTERCAL, the older operators are supported as alternatives; INTERCAL programs may now be encoded in [[ASCII]], [[Latin-1]], or [[UTF-8]].<ref>{{cite web|url=http://c.intercal.org.uk/manual/atvm81sp.htm|archive-url=https://archive.today/20121224065530/http://c.intercal.org.uk/manual/atvm81sp.htm|url-status=dead|archive-date=2012-12-24|title=Princeton and Atari Syntax – C-INTERCAL 0.27 Revamped Instruction Manual|access-date=2012-11-12}}</ref> | ||
== | == Details == | ||
INTERCAL was intended to be completely different from all other computer languages. In the words of the original manual: | |||
{{Quote|text=Any resemblance of the programming language portrayed here to other programming languages, living or dead, is purely coincidental.}} | |||
Common operations in other languages have cryptic and redundant syntax in INTERCAL. From the INTERCAL Reference Manual:<ref name="manual72" /> | |||
{{quote|text=It is a well-known and oft-demonstrated fact that a person whose work is incomprehensible is held in high esteem. For example, if one were to state that the simplest way to store a value of 65536 in a 32-bit INTERCAL variable is: | {{quote|text=It is a well-known and oft-demonstrated fact that a person whose work is incomprehensible is held in high esteem. For example, if one were to state that the simplest way to store a value of 65536 in a 32-bit INTERCAL variable is: | ||
| Line 44: | Line 28: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
any sensible programmer would say that that was absurd. Since this is indeed the simplest method, the programmer would be made to look foolish in front of his boss, who would of course happen to turn up, as bosses are | any sensible programmer would say that that was absurd. Since this is indeed the simplest method, the programmer would be made to look foolish in front of his boss, who would of course happen to turn up, as bosses are wont to do. The effect would be no less devastating for the programmer having been correct. }} | ||
INTERCAL has many other features designed to make it even more aesthetically unpleasing to the programmer: it uses statements such as "READ OUT", "IGNORE", "FORGET", and modifiers such as "PLEASE". This last keyword provides two reasons for the program's rejection by the compiler: if "PLEASE" does not appear often enough, the program is considered insufficiently polite, and the error message says this; if it appears too often, the program could be rejected as excessively polite. Although this feature existed in the original INTERCAL compiler, it was undocumented.<ref name="manualick"/> | INTERCAL has many other features designed to make it even more aesthetically unpleasing to the programmer: it uses statements such as "READ OUT", "IGNORE", "FORGET", and modifiers such as "PLEASE". This last keyword provides two reasons for the program's rejection by the compiler: if "PLEASE" does not appear often enough, the program is considered insufficiently polite, and the error message says this; if it appears too often, the program could be rejected as excessively polite. Although this feature existed in the original INTERCAL compiler, it was undocumented.<ref name="manualick"/> | ||
| Line 96: | Line 80: | ||
|} | |} | ||
Contrary to most other languages, AND, OR, and XOR are [[Unary operation|unary]] operators, which work on consecutive bits of their argument; the [[most significant bit]] of the result is the operator applied to the least significant and most significant bits of the input, the second-most-significant bit of the result is the operator applied to the most and second-most significant bits, the third-most-significant bit of the result is the operator applied to the second-most and third-most bits, and so on. The operator is placed between the punctuation mark specifying a variable name or constant and the number that specifies which variable it is, or just inside grouping marks (i.e. one character later than it would be in programming languages like [[C (programming language)|C]]. | Contrary to most other languages, AND, OR, and XOR are [[Unary operation|unary]] operators, which work on consecutive bits of their argument; the [[most significant bit]] of the result is the operator applied to the least significant and most significant bits of the input, the second-most-significant bit of the result is the operator applied to the most and second-most significant bits, the third-most-significant bit of the result is the operator applied to the second-most and third-most bits, and so on. The operator is placed between the punctuation mark specifying a variable name or constant and the number that specifies which variable it is, or just inside grouping marks (i.e. one character later than it would be in programming languages like [[C (programming language)|C]]). | ||
SELECT and INTERLEAVE (which is also known as MINGLE) are infix binary operators. SELECT takes the bits of its first operand that correspond to "1" bits of its second operand and removes the bits that correspond to "0" bits, shifting towards the least significant bit and padding with zeroes: 51 (1'''1'''0'''0'''1'''1''' in binary) SELECT 21 (10101 in binary) is 5 ('''101''' in binary). MINGLE alternates bits from its first and second operands (in such a way that the least significant bit of its second operand is the least significant bit of the result). | |||
There is no operator precedence; grouping marks must be used to disambiguate the precedence where it would otherwise be ambiguous (the grouping marks available are <code>'</code> ("spark"), which matches another spark, and <code>"</code> ("rabbit ears"), which matches another rabbit ears; the programmer is responsible for using these in such a way that they make the expression unambiguous).<ref name="manual72"/> | |||
=== Control structures === | === Control structures === | ||
| Line 108: | Line 96: | ||
=== Hello, world === | === Hello, world === | ||
The | The following is a [[Hello world program|"Hello, world!" program]] in INTERCAL. | ||
<syntaxhighlight lang="basic"> | <syntaxhighlight lang="basic"> | ||
| Line 150: | Line 126: | ||
A more recent variant is Threaded Intercal, which extends the functionality of COME FROM to support [[Thread (computer science)|multithreading]].<ref name="manualthick">{{cite web|url=http://www.cse.unsw.edu.au/~malcolmr/intercal/threaded.html |title=Threaded Intercal |publisher=Cse.unsw.edu.au |date=2004-06-09 |access-date=2012-03-10}}</ref> | A more recent variant is Threaded Intercal, which extends the functionality of COME FROM to support [[Thread (computer science)|multithreading]].<ref name="manualthick">{{cite web|url=http://www.cse.unsw.edu.au/~malcolmr/intercal/threaded.html |title=Threaded Intercal |publisher=Cse.unsw.edu.au |date=2004-06-09 |access-date=2012-03-10}}</ref> | ||
CLC-INTERCAL has a library called INTERNET for networking functionality including being an INTERCAL server, and | CLC-INTERCAL has a library called INTERNET for networking functionality including being an INTERCAL server, and includes features such as Quantum Intercal, which enables multi-value calculations in a way purportedly ready for the first [[Quantum computing | quantum computers]]. | ||
In early 2017 a [[.NET]] Implementation targeting the [[.NET Framework]] appeared on [[GitHub]]. This implementation supports the creation of standalone binary libraries and interop with other programming languages. <ref name="componentintercal">{{cite web |url=https://github.com/jawhitti/INTERCAL|title=Official home of Simple Component Intercal for .NET |website=[[GitHub]] |date=30 September 2021 }}</ref> | In early 2017 a [[.NET]] Implementation targeting the [[.NET Framework]] appeared on [[GitHub]]. This implementation supports the creation of standalone binary libraries and interop with other programming languages. <ref name="componentintercal">{{cite web |url=https://github.com/jawhitti/INTERCAL|title=Official home of Simple Component Intercal for .NET |website=[[GitHub]] |date=30 September 2021 }}</ref> | ||
| Line 162: | Line 138: | ||
{{quote|If PLEASE was not encountered often enough, the program would be rejected; that is, ignored without explanation by the compiler. Too often and it would still be rejected, this time for sniveling. Combined with other words that are rarely used in programming languages but appear as statements in INTERCAL, the code reads like someone pleading.}} | {{quote|If PLEASE was not encountered often enough, the program would be rejected; that is, ignored without explanation by the compiler. Too often and it would still be rejected, this time for sniveling. Combined with other words that are rarely used in programming languages but appear as statements in INTERCAL, the code reads like someone pleading.}} | ||
== References == | == References == | ||