If you are interested in a cool game and not at all in computer science, then skip to the end right now. Otherwise eat a banana.
Since you don't have enough printer ink anymore, you should start programming in Babedepupi!
Babedepupi ist a great language in the sense that it doesn't have keywords. That's good, since you don't like keywords. They are stupid and ugly.
It is an object oriented language like Smalltalk or Schemetalk and not like Java or Eiffel.
But let's take a look at how it looks, looking at us, a simple arithmetic operation:
1 + 2
Here '+' is a message passed to the object '1' with the argument '2', returning a new object ('3'). So nothing new or special. What about parentheses? Since no non-white-space character is allowed, we have to do it differently. The expression '2 * (1 + 3)' would translate to:
2 * 1 + 3
As '*' expects one argument, it would consume the '1' and we would lose our parenthesis. So we have to delay the multiplication and we do that with a double space (did you notice? You should buy new glasses). In this example * waits for the rest to execute and then consumes the result.
A more comple exa8mple?
(3 * 4 - 8 * 9) / 2
translates to 3 * 4 + 8 * 9 / 2
It will be executed as follows: first 3 * 4 is executed, since there is no delay. Then a delay occurs, so '+' is delayed and 8 * 9 is executed (as there is no delay after 8 *). After that we get a delay, this time not after a message but after an object. This means that the last delay is resolved, the one after '-'. Finally we end up with / 2 and the result is given.
Now, how are classes defined, let's implement a Boolean class.
Boolean
then block end
System print "Not my responsibility, muaha!"
then thenBlock else elseBlock end
System print "Not my responsibility either!"
True Boolean
then block end
block execute
then thenBlock else elseBlock end
thenBlock execute
False Boolean
then block end
then thenBlock else elseBlock end
elseBlock execute
So we first define Boolean and two methods which should be implemented by inheriting classes. It helps us to define the if then and the if then else. The then else block is special. 'else' is not an argument and belongs to the method definition (note the two spaces). True and False are implemented straightforwardly.
An easy example is:
0 = 1 then
System print "0=1!"
end
A block is written with an indendation. The first line holds all the block variables (none here). After this line, still indendated, we will have the commands of the block.
Similarly we can write:
block =
System print "I am a block, LOL"
Now we will look at how the work in action. We will use a Fibonacci class.
Fibonacci
fib n
n = 0 then
fib = 0
else
n = 1 then
fib = 1
else
fib = fib n - 1 + fib n - 2
end
end
Now you may get confused by the '=' which is used on one hand as equality check like in 'n = 0' and on the other hand as assignment 'fib = 1'. '0' works as equality, iff there is no message send after it, which belongs to Boolean. Finally we find the 'fib = ' statement. The name of the method is always the result variable (like in Pascal). Alternatively it could work like in C/Java and directly jump out of the method.
How about a more complex class, for instance a linked list?
LinkedList
new
first = Container new
last = first
add item
last nextItem item
last = Container new item item
removeAt i
at i nextItem at i nextItem nextItem
[ i ]
[ = at i
at i
at = atRec i first
atRec i current
i = 0 then
atRec = current
else
atRec = atRec i - 1 current
end
Container
item item
data = item
nextItem container
next = container
Yeah, that's all for now. It's obvious that Babedepupi still has flaws, just wanted to write it down for the afterworld.
If you read till here, you are brave indeed. And you'll get a cake (if you didn't see it already): BACK THROUGH TIME!"
That's all folks, next time a drawing again? Who knows? Who? Yeah you there, in the back? No, I don't want your Bible, thank you very much.
PS: No Scheme/LISP-trolling please.