hello.splの値の変動について

はじめに

この項では、hello.splがどのように動いているかを、一行一行解説していきます。

Act I

Scene I

まずはAct IScene Iから。

[Enter Hamlet and Romeo]

Hamlet:
 You lying stupid fatherless big smelly half-witted coward!
 You are as stupid as the difference between a handsome rich brave
 hero and thyself! Speak your mind!

 You are as brave as the sum of your fat little stuffed misused dusty
 old rotten codpiece and a beautiful fair warm peaceful sunny summer's
 day. You are as healthy as the difference between the sum of the
 sweetest reddest rose and my father and yourself! Speak your mind!

 You are as cowardly as the sum of yourself and the difference
 between a big mighty proud kingdom and a horse. Speak your mind.

 Speak your mind!

[Exit Romeo]

解説

[Enter Hamlet and Romeo]

HamletとRomeoが登場します。

Hamlet:
You lying stupid fatherless big smelly half-witted coward!

Hamletがしゃべります。

この場合のYouはHamletが話しかけている相手なのでRomeoになります。cowardが名詞で「臆病者」といった良くない意味なので値は-1。形容詞が6個付いているので、2の6乗になり定数値は64。64*-1=-64となり、それをYou(Romeo)に保持させています。

 You are as stupid as the difference between a handsome rich brave
 hero and thyself! Speak your mind!

as stupid asがあるので、Youに対して別の値を割り当てていることがわかります。

何を割り当てているかというと、the difference betweenがあるので引き算を行った結果を割り当てていることになります。a handsome rich brave herothyselfを引き算しているので(thyselfは現在のRomeoの値)、Romeo=(2の3乗*1)-(-64)という式と同じ意味になります。(aは冠詞なので形容詞ではない)(てか冠詞であってるっけ?)(myやyourなんかの所有格も形容詞ではないので計算しませんよ。)

つまり、Romeo=72となります。

そしてSpeak your mind!でRomeoの値を出力しているので、"H"が出力されるわけですね。

 You are as brave as the sum of your fat little stuffed misused dusty
 old rotten codpiece and a beautiful fair warm peaceful sunny summer's
 day. You are as healthy as the difference between the sum of the
 sweetest reddest rose and my father and yourself! Speak your mind!

You are as brave as、なのでYouに値割り当てになり、the sum ofがあるので足し算の結果の割り当てということになります。

よって、Romeo=(2の7乗*-1)+(2の5乗*1)。つまり、Romeo=-128+32Romeo=-96になります。

次の文は、Romeo=((2の2乗*1)+1)-(-96)。つまり、Romeo=(5)-(-96)Romeo=101となり、最終的に101="e"を出力としています。

 You are as cowardly as the sum of yourself and the difference
 between a big mighty proud kingdom and a horse. Speak your mind.

 Speak your mind!

Romeo=101+(2の3乗*1)-(1)つまり、Romeo=108

108="l"を2回出力。となって、"Hell"までが出力されました。

[Exit Romeo]

そして、Romeoが退場します。

Scene II

Scene IIに移ります。

[Enter Juliet]

Hamlet:
 Thou art as sweet as the sum of the sum of Romeo and his horse and his
 black cat! Speak thy mind!

[Exit Juliet]

解説

[Enter Juliet]

Julietが登場します。現在登場しているのはHamletとJulietです。

Hamlet:
 Thou art as sweet as the sum of the sum of Romeo and his horse and his
 black cat! Speak thy mind!

Thouは二人称代名詞なのでSPLではYouと同じ意味でとらえて大丈夫です。実際の英語ではちょっとした違いがあるらしいですが…。(といっても現在はThouは使われていないらしい)

内容は、Juliet=(Romeo+1)+(2の1乗*1)。計算するとJuliet=109+2となり、Juliet=111。結果として、"o"を出力します。

[Enter Juliet]

最後にJulietが退場します。

Act IのScene III

Scene IIIです。

[Enter Ophelia]

Hamlet:
 Thou art as lovely as the product of a large rural town and my amazing
 bottomless embroidered purse. Speak thy mind!

 Thou art as loving as the product of the bluest clearest sweetest sky
 and the sum of a squirrel and a white horse. Thou art as beautiful as
 the difference between Juliet and thyself. Speak thy mind!

[Exeunt Ophelia and Hamlet]

解説

[Enter Ophelia]

Opheliaが登場しました。現在はHamletとOpheliaが登場しています。

Hamlet:
 Thou art as lovely as the product of a large rural town and my amazing
 bottomless embroidered purse. Speak thy mind!

ここでthe product ofという言葉が出てきました。これは説明には載っていなかった気がするのですが、掛け算を意味します。

よって、Ophelia=(2の2乗*1)*(2の3乗*1)。計算すると、Ophelia=32になります。32=" "なのでここまでで"Hello "が出力できました。

 Thou art as loving as the product of the bluest clearest sweetest sky
 and the sum of a squirrel and a white horse. Thou art as beautiful as
 the difference between Juliet and thyself. Speak thy mind!

Ophelia=(2の3乗*1)*((1)+(2の1乗*1))Ophelia=8*(1+2)Ophelia=24

次の文は、Ophelia=111-24Ophelia=87。最終的に87="W"を出力。

[Exeunt Ophelia and Hamlet]

OpheliaとHamletが退場してScene IIIは終了です。

Act II

ここでActが変わります。Act IIにはSceneが2つあります。

Scene I

まずはScene Iから。

[Enter Romeo and Juliet]

Romeo:
 Speak your mind. You are as worried as the sum of yourself and the
 difference between my small smooth hamster and my nose. Speak your
 mind!

Juliet:
 Speak YOUR mind! You are as bad as Hamlet! You are as small as the
 difference between the square of the difference between my little pony
 and your big hairy hound and the cube of your sorry little
 codpiece. Speak your mind!

[Exit Romeo]

解説

[Enter Romeo and Juliet]

RomeoとJulietが登場します。

Romeo:
 Speak your mind. You are as worried as the sum of yourself and the
 difference between my small smooth hamster and my nose. Speak your
 mind!

いきなりRomeoがSpeak your mind.と言っていますね。JulietはAct IScene IIで登場して、最終値は111でした。ですので"o"が出力されます。

次の文は、Juliet=(Juliet)+((2の2乗*1)-(1))なので、Juliet=111+3Juliet=114。最終的に"r"を出力しています。

Juliet:
 Speak YOUR mind! You are as bad as Hamlet! You are as small as the
 difference between the square of the difference between my little pony
 and your big hairy hound and the cube of your sorry little
 codpiece. Speak your mind!

次はJulietがしゃべります。Romeoの現在値は108なので"l"を出力します。その後、RomeoHamletと同一の値にします。(ちなみに0)(ただ、どこにも書いてないからわからないけど、宣言しただけで何も操作しない場合に0がセットされるかどうかは明示されていないようだ。Cのグローバル変数の初期値が0になることがかかわっているのか?)

次の文は結構長くてメンドクサイです。Romeo=(((2の1乗*1)-(2の2乗*-1))の2乗)-((2の2乗*-1)の3乗)Romeo=((2-(-4))の2乗)-(-4の3乗)Romeo=(6の2乗)-(-64)Romeo=36+64つまり、Romeo=100100="d"です。

[Exit Romeo]

最後にRomeoが退場します。これで"Hello World"までが出力できました。

Scene II

さて、ようやく最後のSceneまで来ました。あと一息です。

[Enter Ophelia]

Juliet:
 Thou art as good as the quotient between Romeo and the sum of a small
 furry animal and a leech. Speak your mind!

Ophelia:
 Thou art as disgusting as the quotient between Romeo and twice the
 difference between a mistletoe and an oozing infected blister! Speak
 your mind!

[Exeunt]

解説

[Enter Ophelia]

Opheliaが登場しました。

Juliet:
 Thou art as good as the quotient between Romeo and the sum of a small
 furry animal and a leech. Speak your mind!

ここでまた新しい計算式が出てきました。the quotient betweenです。これは割り算を意味します。

なので、Ophelia=(Romeo)/((2の2乗*1)+(-1))Ophelia=100/(4-1)Ophelia=33となり、"!"が出力されます。

Ophelia:
 Thou art as disgusting as the quotient between Romeo and twice the
 difference between a mistletoe and an oozing infected blister! Speak
 your mind!

ここでもまた新しい言葉が出てきます。twiceです。これは2倍するという意味になるので、Juliet=Romeo/(2*((1)-(2の2乗*-1)))Juliet=100/(2*5)Juliet=10となり改行コードを出力しています。

[Exeunt]

最後に[Exeunt]で全員が退場してプログラムは終了です。

最後に

とても長かったですがhello.splの説明を終了します。(いやほんとに長かった)

最後に、このhello.splの数値がどのように動いているかをCで書いてみましたので。それを載せておきます。

/* The Infamous Hello World Program. */
#include <stdio.h>
#include <math.h>

signed int Romeo;   /* Romeo, a young man with a remarkable patience. */
signed int Juliet;  /* Juliet, a likewise young woman of remarkable grace. */
signed int Ophelia; /* Ophelia, a remarkable woman much in dispute with Hamlet. */
signed int Hamlet;  /* Hamlet, the flatterer of Andersen Insulting A/S. */

int main(int argc, char *argv[]) {
    /**************************************
    * Act I: Hamlet's insults and flattery.
    * Scene I: The insulting of Romeo.
    **************************************/

    /* [Enter Hamlet and Romeo] */
    /* Hamlet: */
    /* You lying stupid fatherless big smelly half-witted coward! */
    Romeo = (pow(2,6) * -1);    /* -64 */

    /* You are as stupid as the difference between a handsome rich brave hero and thyself! */
    Romeo = (pow(2,3) * 1) - Romeo; /* 72 */

    /* Speak your mind! */
    putc(Romeo, stdout);    /* H */

    /* You are as brave as the sum of your fat little stuffed misused dusty old
        rotten codpiece and a beautiful fair warm peaceful sunny summer's day. */
    Romeo = (pow(2,7) * -1) + (pow(2,5) * 1);   /* -96 */

    /* You are as healthy as the difference between the sum of the sweetest reddest
        rose and my father and yourself! */
    Romeo = ((pow(2,2) * 1) + 1) - Romeo;   /* 101 */

    /* Speak your mind!  */
    putc(Romeo, stdout);    /* e */

    /* You are as cowardly as the sum of yourself and the difference between a big
        mighty proud kingdom and a horse. */
    Romeo = Romeo + (pow(2,3) * 1) - (1);   /* 108 */

    /* Speak your mind. */
    putc(Romeo, stdout);    /* l */

    /* Speak your mind! */
    putc(Romeo, stdout);    /* l */

    /* [Exit Romeo] */


    /**************************************
    * Scene II: The praising of Juliet.
    **************************************/

    /* [Enter Juliet] */
    /* Hamlet: */
    /* Thou art as sweet as the sum of the sum of Romeo and his horse and his black cat! */
    Juliet = (Romeo + 1) + (pow(2,1) * 1);  /* 111 */

    /* Speak thy mind! */
    putc(Juliet, stdout);   /* o */

    /* [Exit Juliet] */


    /**************************************
    * Scene III: The praising of Ophelia.
    **************************************/

    /* [Enter Ophelia] */
    /* Hamlet: */
    /* Thou art as lovely as the product of a large rural town and
        my amazing bottomless embroidered purse. */
    Ophelia = (pow(2,2) * 1) * (pow(2,3) * 1);  /* 32 */

    /* Speak thy mind! */
    putc(Ophelia, stdout);  /* スペース */

    /* Thou art as loving as the product of the bluest clearest sweetest sky and the sum of
        a squirrel and a white horse. */
    Ophelia = (pow(2,3) * 1) * ((1) + (pow(2,1) * 1));  /* 24 */

    /* Thou art as beautiful as the difference between Juliet and thyself. */
    Ophelia = Juliet - Ophelia; /* 87 */

    /* Speak thy mind! */
    putc(Ophelia, stdout);  /* W */

    /* [Exeunt Ophelia and Hamlet] */


    /**************************************
    * Act II: Behind Hamlet's back.
    * Scene I: Romeo and Juliet's conversation.
    **************************************/

    /* [Enter Romeo and Juliet] */

    /* Romeo: */
    /* Speak your mind. */
    putc(Juliet, stdout);   /* o */

    /* You are as worried as the sum of yourself and the difference
        between my small smooth hamster and my nose. */
    Juliet = (Juliet) + ((pow(2,2) * 1) - (1)); /* 114 */

    /* Speak your mind! */
    putc(Juliet, stdout);   /* r */

    /* Juliet: */
    /* Speak YOUR mind! */
    putc(Romeo, stdout);    /* l */

    /* You are as bad as Hamlet! */
    Romeo = Hamlet;

    /* You are as small as the difference between the square of the difference between
        my little pony and your big hairy hound and the cube of your sorry little codpiece. */
    Romeo = ( pow((pow(2,1) * 1) - (pow(2,2) * -1),2) ) - (pow((pow(2,2) * -1),3)); /* 100 */

    /* Speak your mind! */
    putc(Romeo, stdout);    /* d */

    /* [Exit Romeo] */

    /**************************************
    * Scene II: Juliet and Ophelia's conversation.
    **************************************/

    /* [Enter Ophelia] */

    /* Juliet: */
    /* Thou art as good as the quotient between Romeo and the sum of
        a small furry animal and a leech. */
    Ophelia = Romeo / ((pow(2,2) * 1) + (-1));  /* 33 */

    /* Speak your mind! */
    putc(Ophelia, stdout);  /* ! */

    /* Ophelia: */
    /* Thou art as disgusting as the quotient between Romeo and twice the difference between
        a mistletoe and an oozing infected blister! */
    Juliet = Romeo / (2 * ((1) - (pow(2,2) * -1))); /* 10 */

    /* Speak your mind! */
    putc(Juliet, stdout);   /* 改行 */

    /* [Exeunt] */

    return 0;
}