We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Catch

From Esolang
Jump to navigation Jump to search

Catch is an esoteric programming language, designed by User:ihope127, in which most statements throw exceptions. A block consists of an if statement followed by a number of others, and it ends right before the next if. The exception is if's inside a catch statement: outside a catch statement, the whole thing is treated as a single instruction, while inside the catch statement, the catch statement is treated as if it were the whole program.

An example "Hello World" program:

if printInst("Hello World!")

Put simply, this throws the printInst exception with the parameter "Hello World!" This exception is not caught, therefore it is transferred to the "default" exception handler, which in this case prints "Hello World!" to the screen.

What makes this an if and not just a throw is how flow is passed: if the exception is left un-caught the flow goes to the "then" statement; if it is caught, flow progresses to the else statement. However, since neither is present in this block, flow simply goes to the next block.

The "Hello World" is extremely simple and rather boring, so we'll create a subtraction program:

if createVariableInst(x) ;create the x variable
if createVariableInst(y) ;create the y variable
if inputInst(x) ;accept input for the x variable
if inputInst(y) ;accept input for the y variable

if subtractInst(x, y, y) ;subtract the two and store the result in y
if printInst(y) ;print the result

A complete list of built-in exceptions has not yet been established.