Remove from this repo specifications that I'm not responsible for.
Chris Pressey
1 year, 7 months ago
3 | 3 | This is a collection of specifications for programming languages that have |
4 | 4 | not been implemented. Indeed, many of them may well be unimplementable. |
5 | 5 | |
6 | Most of them were designed, and their specs written, by Chris Pressey of | |
7 | Cat's Eye Technologies; the exceptions are: | |
8 | ||
9 | * **Startre** and **\*W**, which were designed and written by | |
10 | John Colagioia; and | |
11 | * **TURKEY BOMB**, which (I baldly assert) was found unexpectedly one | |
12 | day under a stack of _Byte_ magazines at a charity shop. | |
6 | With the exception of **[TURKEY BOMB](turkey-bomb/)**, which (I baldly | |
7 | assert) was found unexpectedly one day under a stack of _Byte_ magazines at | |
8 | a charity shop, these languages were designed by, and their specs written by, | |
9 | Chris Pressey of Cat's Eye Technologies. | |
13 | 10 | |
14 | 11 | Also, I say "programming language", but of course that term is rather flexible |
15 | 12 | 'round these parts: |
16 | 13 | |
17 | * **Madison** is a language for writing formal proofs; | |
18 | * **MDPN** is a (two-dimensional) parser-definition language; and | |
19 | * **Opus-2** is a "spoken" language, for some rather exceptional meaning of | |
20 | "speaking". | |
14 | * **[Madison](madison/)** is a language for writing formal proofs; | |
15 | * **[MDPN](mdpn/)** is a (two-dimensional) parser-definition language; and | |
16 | * **[Opus-2](opus-2/)** is a "spoken" language, for some rather exceptional | |
17 | meaning of "speaking". | |
21 | 18 | |
22 | 19 | Most of these specifications are "finished" in the sense that there is nothing |
23 | 20 | obviously more to add to them. (Of course, an implementation, or some really |
25 | 22 | specification.) The exceptions, which can be considered "works in progress", |
26 | 23 | are: |
27 | 24 | |
28 | * **Irishsea**, which is largely a set of notes for a livecoding language. | |
29 | * **Sampo**, which is largely a set of notes for a production language. | |
25 | * **[Irishsea](irishsea/)**, which is largely a set of sketchy notes for a | |
26 | livecoding language. | |
27 | * **[Sampo](sampo/)**, which is largely a set of notes for a production | |
28 | language. | |
30 | 29 | |
31 | The specification documents are copyrighted by their respective authors. Not | |
32 | that I mind if you fork this repo and submit pull requests to fix errors or | |
33 | the like, for such is the nature of the distributed version control beast. | |
30 | ### A Note on the Name of this Repository | |
34 | 31 | |
35 | Note on the name: in the dialect of English where I come from, "spec" is short | |
32 | In the dialect of English that's used where I come from, "spec" is short | |
36 | 33 | for "specification" but "on spec" is short for "on *speculation*." Thus the |
37 | name is trying to convey the idea of specifications that were just kind of | |
38 | pulled out of the air. | |
39 | ||
34 | name is referring to the idea that these language specifications were just | |
35 | pulled out of thin air, rather than being products of deep consideration. |
0 | The Sartre Programming Language | |
1 | =============================== | |
2 | ||
3 | John Colagioia, 199? | |
4 | ||
5 | Introduction | |
6 | ------------ | |
7 | ||
8 | The Sartre programming language is named for the late existential | |
9 | philosopher, Jean-Paul Sartre. Sartre is an extremely unstructured | |
10 | language. Statements in Sartre have essentially no philosophical | |
11 | purpose; they just are. Thus, Sartre programs are often left to define | |
12 | their own functions. | |
13 | ||
14 | Unlike traditional programming languages (or maybe very much like them), | |
15 | nothing in Sartre is guaranteed, except maybe for the fact that nothing | |
16 | is guaranteed. The Sartre compiler, therefore, must be case insensitive | |
17 | (technically, it requires all capital letters, but since nothing matters | |
18 | anyway, why should this?). | |
19 | ||
20 | Names in Sartre may only contain letters (and only capital letters, at | |
21 | that, but nobody really cares that much), and maybe some trailing | |
22 | digits, but nothing else. | |
23 | ||
24 | No standard mathematical functionality is supplied in Sartre. Instead, | |
25 | nihilists are created, which may damage the properties inherent to the | |
26 | data, and nihilators are executed to reclaim storage dynamically. | |
27 | ||
28 | Sartre programmers, perhaps somewhat predictably, tend to be boring and | |
29 | depressed, and are no fun at parties. No comments will be made on the | |
30 | level of contrast between the Sartre programmer and any other | |
31 | programmer. | |
32 | ||
33 | In the words of a Sartre programmer who worked intensely for months, | |
34 | eating whatever junkfood wandered near his cubicle, "I have been gaining | |
35 | twenty-five pounds a week for two months, and I am now experiencing | |
36 | light tides. It is stupid to be so fat. My pain, ultimate solitude, and | |
37 | collection of Dilbert cartoons are still as authentic as they were when | |
38 | I was thin, but seem to impress girls far less. From now on, I will live | |
39 | on cigarettes and black coffee," which is the general diet of the Sartre | |
40 | programmer, for obvious reasons. | |
41 | ||
42 | Comments are available in Sartre, though not at all suggested, since | |
43 | nobody really wants to listen to you, anyway, by typing the comment at | |
44 | the beginning of the line, and terminating it (on the same line) with a | |
45 | squiggle (brace) pair ("{}"). Valid Sartre text may be placed after the | |
46 | comment if desired. If comments are absolutely necessary, they should | |
47 | adequately describe the futility of the program and the plight of | |
48 | programmer and computer in a world ruled by an unfeeling God and His | |
49 | compilers, as well as providing explanation of the surrounding program | |
50 | statements. | |
51 | ||
52 | They should not be misspelled, as some compilers may check. | |
53 | ||
54 | Admittedly, while it is not hard to string Sartre statements together to | |
55 | create a Sartre-compilable text file, it can be quite hard to program in | |
56 | the Sartre paradigm. To wit, one may keep creating programs, one after | |
57 | another, like soldiers marching into the sea, but each one may seem | |
58 | empty, hollow, like stone. One may want to create a program that | |
59 | expresses the meaninglessness of existence, and instead they average two | |
60 | numbers. | |
61 | ||
62 | Sartre Data Types | |
63 | ----------------- | |
64 | ||
65 | The Sartre language has two basic data types, the EN-SOI and the | |
66 | POUR-SOI. The en-soi is a completely filled heap of a specified rank, | |
67 | whereas the pour-soi is a dynamic structure which never has the same | |
68 | value. An integer may also be used in Sartre, but it may only take the | |
69 | value of zero (the Dada extensions to Sartre allow integers to also take | |
70 | on the value of "duck sauce", but that's neither here nor there--unless | |
71 | you happen to like duck sauce, of course). | |
72 | ||
73 | en-soi | |
74 | ||
75 | The en-soi, as mentioned before, is a full heap of a specified rank. As | |
76 | Sartre does not allow pre-initialized data, the actual data in the heap | |
77 | is non-specified (but the heap is "pre-heapified"). Data (en-sois of | |
78 | rank 0) may be "deconstruct"ed from the en-soi, or "rotate"d through. At | |
79 | all times, the en-soi remains a full heap, however. En-sois of rank zero | |
80 | are 32 bits with no inherent meaning. En-sois of higher rank may be | |
81 | defined as each element being of another (same) data type (an en-soi of | |
82 | integers, all with a value of zero (or duck sauce), for example). | |
83 | ||
84 | pour-soi | |
85 | ||
86 | The pour-soi is only, and precisely, what it is not. It may be | |
87 | "unassigned from" a certain value, thereby exactly increasing the number | |
88 | of things it isn't. It is specified to be a two-bit value, so it | |
89 | probably isn't. | |
90 | ||
91 | integer | |
92 | ||
93 | Unlike the integers in most programming languages, Sartre integers all | |
94 | have a value of zero (again, unless the Dada extensions are being used). | |
95 | Like the rest of the dreary universe (duck sauce included), this is | |
96 | something that must be lived with. | |
97 | ||
98 | orthograph | |
99 | ||
100 | The orthograph is a special type of pictogram used in the specification | |
101 | of lexicographic elements. The set of orthographs varies from Sartre | |
102 | implementation to Sartre implementation, but is guaranteed to contain | |
103 | all the so-called "letters" from at least one modern language, | |
104 | transliterated to the closest element of the ASCII set and ordered as | |
105 | the bit-reversed EBCDIC value, assuming those bit-patterns were | |
106 | integers, which they probably aren't. Unavailable orthographs in a given | |
107 | implementation are represented by "frowny faces". As defined, the | |
108 | orthograph is possibly the simplest and most convenient data type to | |
109 | work with. | |
110 | ||
111 | const | |
112 | ||
113 | Not an actual data type, but somewhat useful, is the introduction of the | |
114 | symbolic constant into the Sartre language. Since Sartre does not allow | |
115 | for unconventional, potentially confusing symbols to be strewn about a | |
116 | program (for example, "17" meant to represent a certain quantity of | |
117 | items), this allows the programmer to define a set of symbolic constants | |
118 | he plans to use. To avoid confusion, symbolic constants are defined in | |
119 | unary, using the "wow" (!) as the unit (i.e., !, !!, !!!, !!!!, ...). | |
120 | ||
121 | Symbolic constants must be surrounded in "rabbit ears" (") in use during | |
122 | the action section of the program. | |
123 | ||
124 | Predefined Sartre Instances | |
125 | --------------------------- | |
126 | ||
127 | The following data instances are provided to the Sartre programming | |
128 | environment to facilitate programming certain concepts which would be | |
129 | (and probably should be) nearly impossible otherwise. | |
130 | ||
131 | MAXINT This is the maximum integer value allowed by the | |
132 | particular Sartre implementation: zero. | |
133 | MININT This is the minimum integer value allowed by the | |
134 | particular Sartre implementation. If using the Dada | |
135 | extensions, MININT is duck sauce; if not, it is zero. | |
136 | ORTH0 This is the "initial orthograph" of the Sartre | |
137 | implementation. | |
138 | ORTHL8 This is the "final orthograph" of the implementation. | |
139 | The name is properly pronounced "Orthograph: Lazy | |
140 | Eight". | |
141 | ||
142 | Sartre Program Segments | |
143 | ----------------------- | |
144 | ||
145 | The Sartre program is broken into simple, logical portions. In essence, | |
146 | all things must be declared before usage, and the declaration section | |
147 | comes before the action section (if any). Since the Sartre language has | |
148 | a recursive structure, the Sartre nihilist has the same structure as the | |
149 | main nihilator which is about to be described: | |
150 | ||
151 | Nihilator <name> ; | |
152 | {Nihilist;} | |
153 | Const <name> = <value>; | |
154 | Consts <name> = <value>..<value>; | |
155 | Matter {<name> {, <name>} : <type> ;} | |
156 | Act | |
157 | {<statement> ;} | |
158 | No more ; | |
159 | . | |
160 | ||
161 | The only difference between a nihilist and the nihilator is that a | |
162 | nihilist does not use the trailing one-spot. | |
163 | ||
164 | Example Matter definitions (data declaration) might be: | |
165 | ||
166 | Const 3 = !!; | |
167 | Matter dooM: integer; | |
168 | Rniqqlj:en-soi, rank "3", of pour-soi; | |
169 | ||
170 | which creates an integer (with a value of 0, since we are not invoking | |
171 | Dada extensions), and a heapified en-soi with seven pour-soi storage | |
172 | locations. | |
173 | ||
174 | Sartre Statement Types | |
175 | ---------------------- | |
176 | ||
177 | `IF ;` | |
178 | ||
179 | The Sartre conditional takes no arguments and then alters program flow | |
180 | accordingly. Put simply, on the condition where the most recently | |
181 | executed nihilator was successful, program execution is transferred to | |
182 | just beyond the next conditional, restarting the search from the | |
183 | beginning, if necessary. | |
184 | ||
185 | `LVAL := expr ;` | |
186 | ||
187 | The Sartre assignment statement takes the bourgois-perceived value of | |
188 | the damned expression and places it in LVAL. If LVAL is a pour-soi, this | |
189 | unassigns a value from the pour-soi. | |
190 | ||
191 | `No Exit ;` | |
192 | ||
193 | A reminder to the program that none of us can escape what we have | |
194 | wrought, or even escape what others have wrought. In programming terms, | |
195 | this may either cause the machine to hang or cause the program not to | |
196 | terminate, depending on the implementation. | |
197 | ||
198 | `Life Is Meaningless ;` | |
199 | ||
200 | A special command which, due to the resignation of the programmer, is | |
201 | permitted to perform a wide variety of tasks, among them, alter the | |
202 | direction of program flow, execute a random function, terminate the | |
203 | program, or positionally invert the bits in the data region. Since the | |
204 | programmer doesn't care anyway, this doesn't really matter. In the | |
205 | (tee-hee) ordinary version of Sartre, this operation is defined at | |
206 | compile-time, and is constant at that statement for each incidence of | |
207 | execution. The Dada extensions, however, redefine meaninglessness (since | |
208 | everything under Dada is meaningless to begin with) to be determined at | |
209 | run- time. Further, it may also logically negate each bit in the | |
210 | dataspace under Dada. | |
211 | ||
212 | `{ data } <nihilist> ;` | |
213 | ||
214 | This invokes the named nihilist and allows it to accomplish its goal. | |
215 | ||
216 | The Sartre scoping rules are somewhat complex in that it may only | |
217 | utilize data which has been accessed previously or any data which it | |
218 | makes up itself. Data which has not yet been accessed is unknown to the | |
219 | Sartre nihilist, however. | |
220 | ||
221 | `again ;` | |
222 | ||
223 | Repeats the last statement, for the computationally-impaired. | |
224 | ||
225 | `Act {<statement> ; } No more ;` | |
226 | ||
227 | Allows certain statement-sets to be considered a single, atomic | |
228 | statment. A conditional cannot jump to within such an atomic structure. | |
229 | ||
230 | Predefined Sartre Nihilists | |
231 | --------------------------- | |
232 | ||
233 | `<orthograph> which` | |
234 | ||
235 | Gets replaced with a zero-rank en-soi with the bit pattern of the | |
236 | orthograph. The orthograph may be replaced by a symbolic constant, and | |
237 | returns the bit-pattern that would be associated if the symbolic | |
238 | constant were an integer, which it isn't, otherwise it would be zero. | |
239 | ||
240 | `<zres> that` | |
241 | ||
242 | Gets replaced with the orthograph that matches the bit- pattern in the | |
243 | zero-rank en-soi. | |
244 | ||
245 | `<zres> <zres> <logop>` | |
246 | ||
247 | \<logop\> is one of "and", "or", or "xor", and returns the bitwise | |
248 | logical operation between the two zero-rank en-sois. | |
249 | ||
250 | `NOT <pour-soi>` | |
251 | ||
252 | This makes the pour-soi what it isn't, even if it is. | |
253 | ||
254 | `annihilate ;` | |
255 | ||
256 | Clears the values (sets to arbitrary values) of any data in the program. | |
257 | Proceeds to destroy any dynamically allocated storage. If no dynamic | |
258 | storage exists, causes a "Bad Faith" error in the program. | |
259 | ||
260 | `<zres> Dump ;` | |
261 | ||
262 | Prints the zero-rank en-soi to the screen as up to four orthographs. The | |
263 | en-soi may be replaced with an orthograph, in which case the orthograph | |
264 | itself is printed. | |
265 | ||
266 | `<orthograph> Get ;` | |
267 | ||
268 | Allows an orthograph to be input from the keyboard and stored in the | |
269 | specified orthograph. The orthograph may be replaced by any-rank en-soi | |
270 | of orthographs, in which case the statement will read in enough | |
271 | orthographs to fill the en-soi, then "heapify" the en-soi. | |
272 | ||
273 | `<en-soi> <data> Zip` | |
274 | ||
275 | First, removes an element from the en-soi, then adds the new element and | |
276 | "heapifies," returning the removed element. | |
277 | ||
278 | `<en-soi> Dir` | |
279 | ||
280 | Flips direction of the en-soi's "heapification." If the Dir nihilist is | |
281 | never executed, the heapification of the en-soi is, by default, | |
282 | descending. | |
283 | ||
284 | `<value> <data> Flip ;` | |
285 | ||
286 | Flips the bit represented by \<value\> in \<data\>. | |
287 | ||
288 | `<data> <data> Concat` | |
289 | ||
290 | Returns the concatenated bitpatterns of the two \<data\> elements. | |
291 | ||
292 | Sample Sartre Programs | |
293 | ---------------------- | |
294 | ||
295 | Nihilator SartreExample1; | |
296 | Act | |
297 | No more ; . | |
298 | ||
299 | This program can be appreciated for its ability to not sort the input | |
300 | list of values in ascending order. It's elegance and simplicity in not | |
301 | accomplishing this goal are admirable. To fully appreciate that sorting | |
302 | is the activity being denied the user, as opposed to, say, searching or | |
303 | some sort of filtering, one should stare at the (lack of) program output | |
304 | forever and not turn on the lights when it gets dark. | |
305 | ||
306 | Nihilator SartreExample2; | |
307 | Act | |
308 | IF ; | |
309 | again ; | |
310 | No more ; . | |
311 | ||
312 | This program fully considers the implications of its existance. It | |
313 | begins by questioning itself and, if successful, control flow moves to | |
314 | find the next conditional, of which there is none, so flow wraps to | |
315 | itself. If unsuccessful, it defaults to the "again" statement, which | |
316 | makes the same consideration (of which the condition is now true), | |
317 | wrapping the control flow to the previously executed "IF". |
0 | The \*W Programming Language | |
1 | ============================ | |
2 | ||
3 | John Colagioia, 199? | |
4 | ||
5 | Introduction | |
6 | ------------ | |
7 | ||
8 | The \*W language should be based on the W language which, of course, | |
9 | does not exist. Instead it is based on an assortment of odds and ends | |
10 | which could be useful in languages, but never seem to have been | |
11 | implemented (and definitely shouldn't have been implemented in the same | |
12 | language), combined with some patching added to, firstly, make \*W truly | |
13 | bizarre and, secondly, to make it as functionally complete a language as | |
14 | C and C++ (from which some concepts such as casting have been borrowed, | |
15 | as well as the name convention), for example. The data types should | |
16 | provide enough of a range that any structure may be built up, and | |
17 | includes arbitrary bitstrings, machine independant pointers (useful for | |
18 | a pass-by-reference), name bindings of data (useful for a pass-by-name), | |
19 | allows for homogenous array-like compositions, and has a semi-structured | |
20 | composite data type. All arithmetic expressions are constructed in | |
21 | prefix to preserve continuity with subroutine calls, and include a | |
22 | fairly complete set of arithmetic and bitwise operators and inbuilt | |
23 | functions to execute any calculation. | |
24 | ||
25 | The language is also quite robust in flow control, allowing for | |
26 | conditionals, iteration (bounded and unbounded), function calls, | |
27 | interrupt-driven, and even random execution. To enforce structured | |
28 | programming, however, neither a "go to" or a "come from" statement has | |
29 | been implemented in \*W. | |
30 | ||
31 | To minimize readability, of course, \*W is fully case insensitive, so | |
32 | that Count, COUNT, count, and COunT are all indistinct except under | |
33 | fairly confusing circumstances (which may or may not exist, depending on | |
34 | the implementation). Data instances must begin with an alphabetic | |
35 | character (`a`-`z` or `A`-`Z`), an underscore (`_`), or a hyphen (`-`). | |
36 | The remainder of the name may then be made up of any alphanumeric | |
37 | characters and the underscore, hyphen, and, of course, the right bracket | |
38 | (`]`). Comments are also possible in \*W (though not necessarily | |
39 | suggested as the language is fairly confusing without misspelled and | |
40 | incorrect descriptions of the program to botch things), and may be | |
41 | included in text by placing a double pipe (`||`) at the beginning of a | |
42 | comment, terminated by the doubled end-of-statement marker (`!!`). Such | |
43 | comments may be placed anywhere in the program, and should be completely | |
44 | ignored by the compiler (just as they are by most programmers). This | |
45 | does not mean that comments are equivalent to whitespace. On the | |
46 | contrary, the compiler considers comments to simply not exist, | |
47 | essentially concatenating the strings to either side of the comment. | |
48 | ||
49 | \*W, like most modern languages, is entirely freeform, meaning that | |
50 | statements are not constrained to the dimensions of, say, a punch card, | |
51 | teletype, computer monitor, or three-dimensional, virtual reality | |
52 | programmers' editor. Program format, therefore, is entirely dependant on | |
53 | input device, host computer's character set, and lack of programmer | |
54 | style, though the compiler is permitted (actually somewhat encouraged) | |
55 | to mock poor format style. | |
56 | ||
57 | \*W Data Types | |
58 | -------------- | |
59 | ||
60 | The \*W data types are designed with maximum versatility in mind. With | |
61 | them, any other known (and several unknown) types may be built. In | |
62 | addition, several predefined instances of these types are provided to | |
63 | enhance the language. | |
64 | ||
65 | `bits` A bitstring of arbitrary length. | |
66 | `cplx` A complex number in the mathematical form (A + Bj) where A and B are integers and j is the square root of (-1). Each component of a cplx is specified to have a minimum precision of {-32768 ... 32767}, but may be more, depending on the implementation. | |
67 | `sack` A (semi)structured data type consisting of a collection of elements which can be packed, unpacked, and checked with other data. | |
68 | `dref` A reference to an instance of some data type. | |
69 | `name` A name of another datum. | |
70 | `chrs` A character string of arbitrary length. | |
71 | `hole` A data type with no value. May pose as any type. | |
72 | ||
73 | Predefined \*W Instances | |
74 | ------------------------ | |
75 | ||
76 | The following data instances are provided to the \*W programming | |
77 | environment to facilitate programming certain concepts which would be | |
78 | nearly impossible otherwise. | |
79 | ||
80 | `WORLD` (`bits`) The \*W representation of the outside world. Assigning an expression to WORLD (see below) causes the character represented by the expression to be appended to the computer display. Likewise, using WORLD in an expression represents the value of the next character in the input buffer (if any). | |
81 | `NOWHERE` (`hole`).. NOWHERE is a place to discard things as well as a place to get nothing. Can also be used for comparison purposes. | |
82 | `NL` (`chrs`) NL is a newline character. | |
83 | `POCKET` (`sack`) Data instances local to each subroutine. Both may be used to store any data, but RESULT will be available for the calling routine to read. | |
84 | `RESULT` (`bits`) | |
85 | ||
86 | \*W Program Parts | |
87 | ----------------- | |
88 | ||
89 | Each \*W program is made of several parts. The functions part, which | |
90 | defines any user functions, the stuff part, which defines any instances | |
91 | of data for the program, and the text part, which contains the program | |
92 | instructions, themselves. | |
93 | ||
94 | ### Functions | |
95 | ||
96 | Subprograms which can be used from the Text, in the form. | |
97 | ||
98 | @ name = Stuff Text | |
99 | ||
100 | ### Stuff | |
101 | ||
102 | Declarations of data to be used by the Text portion of the program, with | |
103 | an optional constant initializer. The initial number allows multiple | |
104 | indexed instances to exist. | |
105 | ||
106 | num/name IS type [const] ! | |
107 | num/name , num/name ... ARE ALL type [const] ! | |
108 | AUTOPACKED SACK name [, ... name] HAS type [, ... type] ! | |
109 | ||
110 | ### Text | |
111 | ||
112 | A list of statements, appearing as: | |
113 | ||
114 | TEXT: {statements} :ENDTEXT | |
115 | ||
116 | W Statement Types | |
117 | ----------------- | |
118 | ||
119 | statement % expr ! | |
120 | ||
121 | Runs statement with a probability of expr. If expr is less than 100, the | |
122 | statement is executed that percentage of time. If it is greater, the | |
123 | statement is executed (expr/100) more times, each time decrementing the | |
124 | value of expr by 100, and, if expr ever falls below 100, is subject to | |
125 | the first rule. A negative value for expression works just like a | |
126 | positive value, except only under conditions where program execution | |
127 | runs backward; otherwise, it is treated as a zero. | |
128 | ||
129 | statment UNLESS expr ! | |
130 | ||
131 | The statment is executed whenever encountered except in any cases when | |
132 | expr evaluates to non-zero. | |
133 | ||
134 | statement WHEN expr ! | |
135 | ||
136 | The statement is not executed when encountered, but is instead executed | |
137 | after any statement where expr currently evaluates to non-zero. | |
138 | ||
139 | lval < expr ! | |
140 | expr > lval ! | |
141 | ||
142 | Takes the value of expr and copies it into lval. | |
143 | ||
144 | function (parameters) ! | |
145 | ||
146 | Calls a function with the appropriate parameters. The parameter list | |
147 | must correspond one-to-one with the Stuff list for that function. | |
148 | ||
149 | The scoping rules in \*W are much more simplified than they would have | |
150 | been in W, had it existed: A function may only access data instances | |
151 | declared within itself, including those implicitly defined. | |
152 | ||
153 | -|- (expr) ! | |
154 | ||
155 | If expr is 0, jumps to the end of the current block (see below), | |
156 | otherwise, terminates the current expr blocks. If expr is greater than | |
157 | the current block nesting, it does nothing. If expr is negative, the | |
158 | program terminates. | |
159 | ||
160 | & statement & statement & ... statement && | |
161 | ||
162 | A blocking mechanism for multiple statments. | |
163 | ||
164 | \*W Mathematical Operations | |
165 | --------------------------- | |
166 | ||
167 | `^ X` And the bits of X (yielding a single bit). | |
168 | `. X` Or the bits of X. | |
169 | `? X` Xor the bits of X. | |
170 | `* X` Butterfly the bits of X, i.e., 11001100 becomes 10100101. | |
171 | `- A B` If A and B are simple (bits, cplx, chrs, hole), identical types, subtracts B from A. | |
172 | `/ A B` If A and B are numeric (cplx), divides A by B. | |
173 | `# A B` If A and B are numeric (cplx), takes A to the B power. | |
174 | `$ A B` Mingles B with A. | |
175 | `~ A B` Selects the B bits from A. | |
176 | `SIZE X` Returns the size of X, in full bytes (rounded up if X is a bitstring). | |
177 | ||
178 | \*W Sack Operations | |
179 | ------------------- | |
180 | ||
181 | PACK sack data: Add data to sack. | |
182 | UNPACK sack data: Remove a data-like element from sack. | |
183 | UNPACK sack: Remove an element from sack. | |
184 | CHECK sack data: Examine sack for data. | |
185 | WEIGH sack: Returns the weight of the sack (in bits). | |
186 | ||
187 | Other \*W Operations | |
188 | -------------------- | |
189 | ||
190 | NAME name AFTER data: Assigns the name of data to name. | |
191 | WHOIS (data): Returns name suggested by data. | |
192 | REF (data): Returns a reference to data. | |
193 | DATA (dref): Returns the data referred to by ref. | |
194 | FCHRS (chrs): Returns the first character of the string. | |
195 | LCHRS (chrs): Returns the last character of the string. | |
196 | FBIT (bits): Returns the first (lowest) bit of the bits. | |
197 | LBIT (bits): Returns the last (highest) bit of the bits. | |
198 | ||
199 | Sample \*W Programs | |
200 | ------------------- | |
201 | ||
202 | 1. Functions: | |
203 | || No functions for this program !! | |
204 | Stuff: | |
205 | 1/Hello is chrs! | |
206 | 1/Sz, 1/Total are all cplx! | |
207 | Text: | |
208 | || Initialize the data !! | |
209 | Hello < "Hello, World!"! | |
210 | Size Hello > Sz! | |
211 | Total < 0! | |
212 | || Take the string length and multiply by 100 !! | |
213 | - Size - 0 Total > Total %10000! | |
214 | || Print and delete a character that many times !! | |
215 | & WORLD < FCHRS (Hello)! | |
216 | & Hello < - Hello FCHRS (Hello)! | |
217 | && %Total! | |
218 | || Add a newline !! | |
219 | WORLD < nl! | |
220 | :Endtext | |
221 | Result: Prints "Hello, World!" to the screen, followed by a | |
222 | newline. | |
223 | 2. Functions: | |
224 | @ mult = | |
225 | Stuff: | |
226 | 1/A, 1/B are all cplx! | |
227 | Text: | |
228 | cplx (RESULT) < 0! | |
229 | cplx (RESULT) < - cplx (RESULT) - 0 B | |
230 | %10000! | |
231 | bits (B) < RESULT! | |
232 | cplx (RESULT) < 0! | |
233 | cplx (RESULT) < - cplx (RESULT) - 0 A | |
234 | %B! | |
235 | :Endtext | |
236 | @ fact = | |
237 | Stuff: | |
238 | 1/n is cplx! | |
239 | Text: | |
240 | RESULT < bits (1)! | |
241 | RESULT < bits (mult (n, - n 1)) | |
242 | unless - 1 ?n! | |
243 | :Endtext | |
244 | Stuff: | |
245 | 1/Input, 1/Output are all chrs! | |
246 | 1/SR is chrs "0"! | |
247 | 1/Num, 1/Out, 1/Place, 1/Index, 1/Mod are all cplx 0! | |
248 | Text: | |
249 | WORLD > Input! | |
250 | Place < 1! | |
251 | Index < cplx (mult (SIZE Input, 100))! | |
252 | & Num < - Num - 0 cplx (mult (Place, | |
253 | - LCHRS (Input) ZR))! | |
254 | & Input < - Input LCHRS (Input)! | |
255 | & cplx (mult (10, Place)) > Place! | |
256 | && %Index! | |
257 | cplx (fact (Num)) > Out! | |
258 | & - Out cplx (mult (/ Out 10, 10)) > Mod! | |
259 | & + 100 / Out 10 > Out! | |
260 | & + Output chrs (+ Mod Zr) > Output! | |
261 | && %%Out! | |
262 | Size Output > Index! | |
263 | Index < cplx (mult (100, Index))! | |
264 | & WORLD < LCHRS (Hello)! | |
265 | & Hello < - Hello LCHRS (Hello)! | |
266 | && %Index! | |
267 | WORLD < nl! | |
268 | :Endtext | |
269 | Result: Accepts a positive integer (n) as input, then outputs | |
270 | the factorial of n (n!). |