CLWPAJNTA 2.0

A bunch of random ideas put together in a programming language.

Its name stands for "Computer Language With Pronounceable Acronym, Just Not This Acronym". Its name, along with some of its features, is inspired by Compiler Language With No Pronounceable Acronym (abbreviated INTERCAL).

Lexical stuff

Comments are like in C++ and Java (// to the end of the line, or between /* and */). Whitespace mostly doesn't matter. String literals are surrounded by single or double quotes and can contain similar escapes to C++.

Parentheses, square brackets, and braces must match but are otherwise completely interchangeable (except within strings).

Data

The main data types are numbers and strings.

General

variable = value
Assignment. If a complex expression is on the left, it is treated as the name of a variable. All variables are global.
value ? value, value value
Test for equality and inequality, respectively. Returns 1 for true and 0 for false. may also be written !=.
( expression )
Override precedence.

Numeric

+ - * / % ^
Addition, subtraction, multiplication, division, modulo, power
number ± number
Choose a random number with a 95% probability of being in the specified range (normal distribution). ++ may be used instead.
< >
Compare. <= and >= are also available for Unicodiphobes.
int( number )
Convert a number to an integer, truncating.

Stringy

makeMoreStringy(value), makeLessStringy(value)
Convert to and from a string.
string + string
Concatenate
string - string
Remove prefix or return 0 if it doesn't have the prefix.
string * number
Repeats the string the specified number of times.
truck(string)
Returns the first half of a string. Equivalent to string * .5.
asky(values)
Convert between Unicode values and strings. If a multi-character string is specified, chooses a random character. If an empty string is specified, returns an empty string.

Data unstructures

something(values)
Put some data in.
something()
Get some data out (chosen randomly)
nothing(values)
Remove some values
nothing()
Remove all values

Dynamic scoping

imagine statement
Makes all variables local (dynamically scoped) and suppresses side effects outside the imagine statement. (ask() will return a random number if imagined.)

I/O

answer( values )
Output the specified values. No spaces or newlines are output implicitly. An empty argument list clears the output.
ask()
Inputs a value as a string and returns it.

Control flow

Basic

statement ; statement
The most basic combination of statements. Chooses one randomly to execute. Any number of statements can be combined this way, and by default get equal probability; parentheses can change the probability.
statement then statement
Sequence.

Loops

wild statement
Executes the statement a random number of times.
too(initializer, condition) statement
Half of a for loop. Executes the initializer, then executes the statement, too. The condition is not tested the first time through the loop.

Deciding when to do things

always statement
Execute the statement between each statement. Starts when this statement is encountered.
sometime statement
Execute the statement at some undetermined point in the future (unless the program exits first).
sometimes statement
Sometimes the statement will execute, other times it won't. Equivalent to because(0±1>0).
never statement
Doesn't execute the statement. Equivalent to because(0).
neverEver statement
Doesn't execute any similar statement. "Similar" meaning assigning the specified value to a specified variable or calling the specified function with the specified arguments (which are evaluated when the neverEver statement is encountered).
procrastinate(variables) statement
Executes the statement "later". Unlike normal lazy evaluation, evaluation of the statement doesn't happen automatically when you try to use the result. The specified variables are saved and restored when the program gets around to executing the statement; of course, such a lazy construct won't clean up those variables afterwards.
deadline(result of a procrastinate statement)
Executes a procrastinated statement. If no statement is specified, executes the next statement in the order they were procrastinated.

Other

please statement
Makes the interpreter more eager to execute the statement. In fact, it may be so eager that it executes it more than once. Equivalent to because(1,1).
because(conditions) statement
Gives the interpreter a reason to execute the statement. It is an error if the reason is invalid. Other effects depend on the surrounding statement, particularly the ; and then operators and the bodies of wild loops and superroutines.
goAway()
Exits the program.

Superroutines

When entering the main program or a superroutine, the interpreter searches for any superroutines it contains. If it finds one that returns to the calling superroutine (initially main), it executes that instead of whatever it would have otherwise executed (choosing randomly if necessary).

super name body
Declares a superroutine, but otherwise acts as a never statement.
(value) superroutine name
Returns to the specified superroutine. Acts as a never statement if the wrong superroutine name is specified.
call()
Call the main program or enclosing superroutine, which may in turn call a different nested superroutine. It is an error for this statement to occur in the main program.

Applet

Type code in the top part and click Run; output will appear in the bottom part; input goes in the line at the very bottom. Warning: Do not double-click the Run button because it may crash your browser. Requires Java 1.5+.

Your browser doesn't support applets

Download (125 KB), Download source (19 KB) (these also include Try and 42)