Whitespace (programming language): Difference between revisions

Content deleted Content added
Tag: Reverted
No edit summary
Tags: Mobile edit Mobile web edit Advanced mobile edit
 
(4 intermediate revisions by 3 users not shown)
Line 4:
[[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|esoteric]] [[programming language]] with [[syntax]] where ''only'' [[whitespace characters]] ([[Space character|space]], [[Tab character|tab]] and [[linefeednewline]]) have meaning {{endash}} contrasting typical languages that largely ignore whitespace characters.
<ref name="whitespace">{{cite web|url=http://compsoc.dur.ac.uk/whitespace/tutorial.php|title=Whitespace|website=Compsoc|access-date=2015-12-08|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><ref name=parker>{{cite book|title=Humble Pi: a comedy of maths errors|publisher=Allen Lane|date=2019|first=Matt|last=Parker|author-link=Matt Parker|ISBN=978-0-241-36023-1|page=21}}</ref>
 
Line 23:
== Syntax ==
 
Whitespace defines a command as a sequencessequence of whitespace characters. For example, <code>[Tab][Space][Space][Space]</code> performs arithmetic addition of the top two elements on the stack.
 
A command is written as an instruction modification parameter (IMP) followed by an operation and then any parameters.
Line 157:
<code><span style="color:#ffffff;background:#ff9999">space</span></code>,
<code><span style="color:#ffffff;background:#9999ff">tab</span></code>, and <code>linefeed</code>.
{{not a typo start}}
 
S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>L:Push_+1001000=72='H'_onto_the_stack&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>:Output_'H';_S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>L:Push_+1100101=101='e'_onto_the_stack&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>:Output_'e';_S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>L:+1101100=108='l'&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>L:+1101100=108='l'&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>L:+1101111=111='o'&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>L:+101100=44=','&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>L:+100000=32=Space&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>L:+1110111=119='w'&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>L:+1101111=111='o'&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>L:+1110010=114='r'&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>L:+1101100=108='l'&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>L=+1100100=100='d'&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>T<span style="background:#9999ff">&#9Tab;</span>L:+100001=33='!'&#10;T<span style="background:#9999ff">&#9Tab;</span>L&#10;S<span style="background:#ff9999">&#32;{{sp}}</span>S<span style="background:#ff9999">&#32;{{sp}}</span>:Output_'!';_L&#10;L&#10;L:End_the_program&#10;
{{not a typo end}}
 
When Whitespace source code is displayed in some browsers, the horizontal spacing produced by a tab character is not fixed, but depends on its ___location in the text relative to the next [[Tab key#HTML|horizontal tab stop]]. Depending on the software, tab characters may also get replaced by the corresponding variable number of space characters.
 
Line 168:
==External links==
 
*{{Official website|https://wwwweb.espacoinvisivelarchive.netorg/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.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