ⓘ Shakespeare Programming Language

                                     

ⓘ Shakespeare Programming Language

The Shakespeare Programming Language is an esoteric programming language designed by Jon Åslund and Karl Hasselstrom. Like the Chef programming language, it is designed to make programs appear to be something other than programs; in this case, Shakespearean plays.

A character list in the beginning of the program declares a number of stacks, naturally with names like "Romeo" and "Juliet". These characters enter into dialogue with each other in which they manipulate each others topmost values, push and pop each other, and do I/O. The characters can also ask each other questions which behave as conditional statements. On the whole, the programming model is very similar to assembly language but much more verbose.

                                     

1.1. Programming in Shakespeare Dramatis Personae

This is the section where variables are declared. Each variable can hold a signed integer value and is of the following form:

Name, Description

Where Name is the name of the variable and Description is ignored by the compiler. The compiler will only recognize names that correspond to actual Shakespearean characters.

                                     

1.2. Programming in Shakespeare Acts and scenes

A piece of code in Shakespeare is broken into Acts which contain Scenes in which characters variables interact. Each Act and Scene is numbered with a Roman numeral and serves as a GOTO label. Any code after the colon is considered a comment. They are written in the form:

Act I: Hamlets insults and flattery. Scene I: The insulting of Romeo.
                                     

1.3. Programming in Shakespeare Enter, exit and exeunt

Individual lines of code generally take the form of a piece of dialogue spoken by one character to another; this is how the value of a variable the character spoken to is assigned, changed, or output. A character can only be addressed as "you". Thus, there must typically be exactly two characters "on stage" whenever lines are spoken: one to speak, and the other to be spoken to. To call a variable to the stage the Enter command is used with a list of one or more characters. The Exit command tells exactly one listed character to leave the stage. Exeunt calls more than one character to leave, or in the case that no characters are listed all the characters will leave the stage. The following format is used:

as" represent a test for equality, while "better" and "worse" correspond to greater than and less than, respectively. A subsequent line, starting "if so" or "if not", determines what happens in response to the truth or falsehood of the original condition. A goto statement begins "Let us", "We shall", or "We must", continues "return to" or "proceed to", and then gives an act or scene. A scene will be parsed as that scene in the current act; a goto statement cannot call a scene in a different act. A conditional statement to call a goto would look like this: Juliet: Am I better than you? Hamlet: If so, let us proceed to scene III.


                                     

1.4. Programming in Shakespeare Pushing and popping stacks

Each variable is a stack. A variable will have an integer pushed onto its stack if a line tells the character to "remember" an appropriate value, such as "Remember me", or "Remember yourself". The topmost value in the stack is popped i.e., the variable assumes this value if the character is told to "recall" anything; all text after this word is treated as a comment.

                                     

2. Example code

This is the standard "Hello World" program that outputs or displays "Hello World!" to the user in SPL.

The Infamous Hello World Program. Romeo, a young man with a remarkable patience. Juliet, a likewise young woman of remarkable grace. Ophelia, a remarkable woman much in dispute with Hamlet. Hamlet, the flatterer of Andersen Insulting A/S. Act I: Hamlets insults and flattery. Scene I: The insulting of Romeo.