Whitespace (programming language): Difference between revisions

Content deleted Content added
TepigMC (talk | contribs)
Add copy and swap operations from
TepigMC (talk | contribs)
Replace Whitespace 0.2 tutorial links with 0.3 link; mention wspace/corpus
Line 2:
[[File:Whitespace in vim2.png|right|206px|thumb|Whitespace [[hello world program]] with syntax highlighting {{legend|#0000ab|tabs}} {{legend|#ab0000|spaces}}]] <!-- make SVG file -->
 
'''Whitespace''' is an [[esoteric programming language]] developed by Edwin Brady and Chris Morris at the [[University of Durham]] (also developers of the [[Kaya (programming language)|Kaya]] and [[Idris (programming language)|Idris]] programming languages). It was released on 1 April 2003 ([[April Fool's Day]]). Its name is a reference to [[whitespace character]]s. Unlike most programming languages, which ignore or assign little meaning to most whitespace characters, the Whitespace interpreter ignores any non-whitespace characters. Only [[Space character|spaces]], [[Tab character|tabs]] and [[linefeed]]s have meaning.<ref name="whitespace">{{cite web|url=http://compsoc.dur.ac.uk/whitespace/tutorial.php|title=Whitespace|website=Compsoc|access-date=2015-1012-2608|url-status=dead|archive-url=https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php|archive-date=18 June 2015}}</ref> A consequence of this property is that a Whitespace program can easily be contained within the whitespace characters of a program written in another language, except possibly in languages which depend on spaces for syntax validity such as [[Python (programming language)|Python]], making the text a [[polyglot (computing)|polyglot]].
 
The [[programming language|language]] itself is an [[imperative programming|imperative]] [[stack-based language]]. The [[virtual machine]] on which the programs run has a stack and a [[dynamic memory allocation|heap]]. The programmer is free to push arbitrary-width integers onto the stack (currently there is no implementation of floating point numbers) and can also access the heap as a permanent store for variables and [[data structure]]s.
Line 15:
Data is represented in [[Binary code|binary]] using spaces (0) and tabs (1), followed by a linefeed; thus, space-space-space-tab-space-tab-tab-linefeed is the binary number 0001011, which is 11 in decimal. All other characters are ignored and thus can be used for comments.
 
Code is written as an ''Instruction Modification Parameter'' (IMP) followed by the operation.<ref name="tutorialwhitespace">{{cite web|url = http://compsoc.dur.ac.uk/whitespace/tutorial.html|title = Whitespace Tutorial|website = CompSoc.dur.ac.uk|access-date = 2015-12-08|url-status = dead|archive-url = https://web.archive.org/web/20151101230744/http://compsoc.dur.ac.uk/whitespace/tutorial.html|archive-date = 1 November 2015}}</ref> The table below shows a list of all the IMPs in Whitespace.
{| class="wikitable"
|-
Line 31:
|}
 
Each IMP is followed by one operation defined for that IMP, and a parameter if needed. The list of operations supported in Whitespace is:<ref name="tutorialwhitespace"/>
 
{| class="wikitable"
Line 85:
| [Tab][LF] || [Tab][Tab] || - || Read a number and place it in the ___location given by the top of the stack
|}
 
The "copy" and "slide" operations were added in Whitespace 0.3 and may not be supported by all implementations.<ref name="whitespace"/>
 
==Sample code==
Line 108 ⟶ 110:
 
==External links==
*{{Official website|https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.html php}}
*[http://developers.slashdot.org/article.pl?sid=03/04/01/0332202 Release announcement on Slashdot]
*[https://github.com/wspace/corpus The Whitespace Corpus] A collection of interpreters, compilers, and programs for Whitespace
*[https://github.com/hostilefork/whitespacers/ Collection of Whitespace interpreters in various script languages]
*[http://metacpan.org/module/Acme::Bleach Acme::Bleach] A [[Perl]] module that rewrites the body of your module to a whitespace-only encoding ("for ''really'' clean programs").