Whitespace (programming language): Difference between revisions

Content deleted Content added
Reverting vandalism by 45.62.76.35
Added missing labels explanation and clarified how numbers are stored. I also prettified the article a little :)
Line 13:
 
== Syntax ==
Commands are composed of sequences of spaces, tab stops and linefeeds. All other characters are ignored and thus can be used for comments. For example, tab-space-space-space performs arithmetic addition of the top two elements on the stack.
Data is represented in [[Binary code|binary]] using spaces (0) and tabs (1), followed by a linefeed; thus, tab-space-space-tab-space-tab-tab-linefeed is the binary number 1001011, which is 75 in decimal. All other characters are ignored and thus can be used for comments.
 
The sign of a number is given by its first character, [Space] for positive and [Tab] for negative.<ref name="whitespace" />
 
Code is written as an ''Instruction Modification Parameter'' (IMP) followed by the operation.<ref name="whitespace" /> The table below shows a list of all the IMPs in Whitespace.
Line 90 ⟶ 87:
 
The "copy" and "slide" operations were added in Whitespace 0.3 and may not be supported by all implementations.<ref name="whitespace"/>
 
=== Numbers ===
Numbers are composed of spaces (0) and tabs (1), and they are terminated by a linefeed. The first space/tab in the number represents the sign of the number, if it's a space the number is positive, if it's a tab the number is negative. The rest of the trailing spaces and tabs represent the rest of the binary number.
 
==== Examples ====
 
space-tab-space-space-tab-space-tab-tab-linefeed (STSSTSTTL) represents the binary number 1001011 (positive, because the number starts with a space) => 75 in decimal.
tab-tab-tab-space-space-tab-space-linefeed (TTTSSTSL) represents the binary number 110010 (negative, because the number starts with a tab) => -50 in decimal.
 
=== Labels ===
Labels are simply [LF] terminated lists of spaces and tabs. There is only one global namespace so all labels must be unique.<ref name="whitespace"/>
 
==Sample code==