Plan du site  
pixel
pixel

Articles - Étudiants SUPINFO

Shakespeare - Scene I

Par Hamza ACHBANI Publié le 19/04/2017 à 17:23:34 Noter cet article:
(0 votes)
En attente de relecture par le comité de lecture

Shakespeare programming language is an esoteric programming language, designed and implemented by Kalle Hasselström and Jon Åslund. design goal was to make a language with beautiful source code that resembled Shakespeare plays. There are no fancy data or control structures, just basic arithmetic and gotos. Shakespeare is the precise opposite of Brainfuck . While the latter reduces syntax and structure to just a bunch of symbols, the prior reimagines code as beautiful Shakespeare plays. the two creator didn't make an SPL compiler, just an SPL to C converter. This proved to be fairly simple, since SPL can be translated directly to C, one statement at a time.




Syntax

► Variables are declared in a section called Dramatis Personae, each one declared within a Shakespeare program must have the name of a Shakespearean character, or it will be ignored by the compiler; it can hold a signed integer value. Name, Description Where Name is the name of the variable and Description is ignored by the compiler.


►Shakespearian code is divided into smaller parts, Acts and Scenes, the code consists of one or more scenes, and each scene consists of lines where the characters say something and enter and exit statement, which cause characters to get on and off the stage.

        		Act I: Hamlet's insults and flattery.
Scene I: The insulting of Romeo.


► To be able to speak their lines, characters must be on stage, The character they address as "you" or "thou" must be also on stage. “Enter” is followed by a list of one or more characters. “Exit” is followed by exactly one character. The plural of Exit is “Exeunt”, which is followed by a list of at least two characters – or none, in which case everyone leaves. An Enter directive given to a character already on stage, or the other way around, will cause a runtime error.

			[Enter Juliet]
			[Enter Romeo and Juliet]
			[Exit Romeo]
			[Exeunt Romeo and Juliet]
			[Exeunt]
			


► Lines : Scenes are further divided into lines. Characters on stage can talk to each other. character : sentences. In the above syntax, it is assumed that the sentence is made by that particular character, and the use of terms like "You" denotes the second person on the stage.


► Constants : a noun is a constant. It has got a value = 1, if the noun is nice, for example "flower" or if it is a neutral noun, for example "tree". If the noun is dirty like "pig" it has a value = -1. When a noun is prefixed with an adjective, it has the effect of multiplying by two. For example, a "beautiful flower" has a value = 2 (2 * 1). Another adjective added, again multiplied by two and so on. For example, "fat dirty pig" has a value = (2 * 2 * -1).


► Input To read a number, use the sentence Listen to your heart . To read a character, use Open your mind . The value will be assigned to the character being spoken to.


► Output : There are two different output sentences, Open your heart and Speak your mind . The first causes the character being spoken to to output her or his value in numerical form, and the other, being more literal, outputs the corresponding letter, digit, or other character, according to the character set being used by your computer.


► Conditional statements : they come in two easy steps, as illustrated by the followingcode fragment:

			Juliet:
				Am I better than you?
			Hamlet:
				If so, let us proceed to scene III.
			

First, someone voices a question. This is some sort of comparison, which will be either true or false. But more on that later. Then comes, at some later point, a conditional statement. This is constructed by putting either “if so” (or “if not”) and a comma in front of any sentence – that sentence is only executed if the answer to the last question was yes (or no). This is pretty much like how you would do conditional jumps and things in many assembly languages.

Conclusion

Although SPL wasn’t created for mainstream use. it has an elegant source code, making it one of the most beautiful turing-complete programming languages.

A propos de SUPINFO | Contacts & adresses | Enseigner à SUPINFO | Presse | Conditions d'utilisation & Copyright | Respect de la vie privée | Investir
Logo de la société Cisco, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société IBM, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sun-Oracle, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Apple, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sybase, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Novell, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Intel, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Accenture, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société SAP, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Prometric, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Toeic, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo du IT Academy Program par Microsoft, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management

SUPINFO International University
Ecole d'Informatique - IT School
École Supérieure d'Informatique de Paris, leader en France
La Grande Ecole de l'informatique, du numérique et du management
Fondée en 1965, reconnue par l'État. Titre Bac+5 certifié au niveau I.
SUPINFO International University is globally operated by EDUCINVEST Belgium - Avenue Louise, 534 - 1050 Brussels