From Incidents to Haphazards

 

 

 

Fish Programming
in a Nutshell

 


Contents

 

Preface _________________________________4

 

Introduction _______________________________5

Fish Underwater Programming Environment

 

Part I

Fish Underwater Programming Environment Architecture

 

Chapter 1 _________________________________6

Fish Colorful Workspace Architecture

 

Chapter 2_________________________________8

The Fish Virtual Machine

 

Chapter 3_________________________________9

The Principles of Incidental Programming

 

Part II

FiPL – The Fish Programming Language

 

Chapter 4_________________________________10

Assignments and the Like

 

Chapter 5_________________________________11
Buddies, Horde and All the Fish

 

Chapter 6_________________________________14

Scale and Tail color arithmetic

 

Chapter 7_________________________________16

Flip-Flops and Haphazards

 

Chapter 8_________________________________17

Incidents and Aftermaths

 

Chapter 9_________________________________19

Abstract Incidents, Commands, Masters and Apprentices


Chapter 10_________________________________21

Thanks For All the Fish

 

Chapter 11_________________________________22

Examples

 

Appendix A_________________________________26

Glossary

 

Appendix B_________________________________28

Predefined colors

 

Colophon__________________________________29

 

Preface

 

I

n the XVIII century Japanese poet Buson wrote the following masterpiece of haiku poetry:

 

The light of day, -
From the head of the it came
This morning.

 

This verse has made such a strong impact on the author that he immediately started to work - first, on the programming language that would help him to program the Fish, and finally on the integrated development environment for this language. Thus, Fish Underwater Programming Environment was born.

 

 

The Audience for this Book

 

This book is for all enlightened people with Zen in mind, interested in the new exciting technology of Fish Programming.

 

Background Information

 

No prerequisites are required, except some skills in diving, fishing, painting and perhaps poetry.

 

Conventions in This Book

 

Courier font is used to show the contents of code lines and some keywords.

Italic is used to indicate the basic concepts of FUPE and FiPL.

 

Acknowledgments

 

This book would not have been written without the influential work of Buson and an inspirational graphics of Andrzej Kot.

Author also wants to thank Don Knuth for his book Things a Computer Scientist Rarely Talks About, where the author learned about the fish picture by Kot illustrating the verse 3:16 of the 2 Book of Kings in Knuth’s own 3:16 book.

 

 

Elijah declared, “Here is what God says:
Pools of water will fill this dry riverbed”.

2 Kings, 3:16

 

 

 

 Introduction

Fish Underwater Programming Environment

 

F

UPE (Fish Underwater Programming Environment) consists of four parts:

 

 

There is not much to be said about FIDE. Its simple user interface will help you to compile and run your programs, as well as to watch the results.

In the following chapters you will learn about FCW and FVM in greater details. The second part of this book describes the complete syntax of FiPL with numerous examples that will help you master the Programming Language of the Fish.


Part I

 

Fish Underwater Programming Environment Architecture

 

 

Chapter 1

Fish Colorful Workspace Architecture

 

F

ish Colorful Workspace (FCW) may be seen as both the FUPE’s memory space and the IO console. It consists of 52 Fish scales numbered from 0 to 51 and 5 Fish tails numbered from 1 to 5.

In the figure below you can see the layout of the scales and tails on the FCW:

 

 

Scales and tails can be referred to following the convention: scale’s name is in the interval S0-S51, tail’s name is in the interval T1-T5 (case insensitive).

 

S

cale is a basic entity of FCW. Its functions are numerous. Usually scale holds color information, however it may have several other responsibilities, such as issuing commands, being a master for other scale or being an apprentice of other scale. One of the most important functions of scale is that it can produce incidents.

Scales can be organized in various groups: buddies, horde or all the fish. All these matters you will learn in the second part of the book. There is no parallel to scales in the familiar computers.

 

T

ail, in contrast to scale, has only one function: it can store the color information. But, doing this tail guarantees that this information is safe – unless the direct assignment will replace this tail’s color. One can regard tail as a general-purpose register of the familiar computer architecture.

 

By default, in the beginning of the FVM running all scales and tails are colored in WHITE (255,255,255).

 

 

T

he exciting feature of FCW is that it can be changed by any other scales-tails configuration, ideally by programmer’s demand on the fly. In the future FUPE releases this feature will be implemented.

 

Chapter 2

The Fish Virtual Machine

 

F

ish Virtual Machine (FVM) is a driving force of the FUPE. It executes the program written in FiPL and displays the results on FCW.

 

The lifecycle of FVM consists of the infinite number of consequent stages, called Fish Cycles.

The first cycle of Fish’s life begins when the programmer starts a program (by pressing the “Run” button in FUPE, for example). The colors of all the FCW scales and tails at the first stage will be determined by the initial color assignments made by the programmer. The important thing to note here is: if two assignments are made at the same cycle, they cannot influence one another. Let’s look at the example:

 

S1 is RED;

T1 is like S1;

 

In an iterative language, one can expect T1 to become RED (like S1). But in the Fish language these two assignments are made on the same cycle; that means, change in the S1’s color will not alter the T1’s color. Instead, T1 will be assigned the previous color of S1. On the next cycle, S1 will become RED and T1 will be colored by the previous S1’s color.

FVM is said to perform an atomic execution within one cycle: everything happens simultaneously, as an atomic operation, and what matters to the next cycle is only the final color state of all the scales together.

 

Once, all the colors of FCW are determined and displayed, the Fish is advanced to the next cycle. Usually, this cycle will reflect all the changes made to scales and tails by the assignment statements issued in the aftermath and command bodies on the previous cycle. Besides, there will be color changes of flip-flops and haphazards. You will learn about these concepts in the second part of the book.

When the second cycle of the Fish is fully settled, next cycle is processed, and so on ad infinitum (in FUPE, the programmer can press the “Stop” button, or the thanks for all the fish operator is executed).

 

T

he important feature to note here: if no scale or tail changes its color during a cycle, the FVM will report that no incidents happen on this cycle, and stops execution automatically.


Chapter 3

The Principles of Incidental Programming

 

T

he concept of incident is very simple. Every change in the color of a scale is regarded as an incident that happened in the FCW. Thus, if one assigns a new color to a scale, this action will cause an incident. This scale is called master of the incident.

 

However, not every incident has a meaning. It does only in case there is an interested party of this incident inside the FCW. This party may be another scale (or group of scales) that has declared that it will obey the commands coming from the master scale by means of an incident. Such a scale is called apprentice of the master of the incident. Command is the sequence of actions that will take place when an incident happens.

Thus, the whole scenario is like this:

 

  1. An incident is declared to happen when the color of a master scale changes to TheColor.
  2. A command is declared to consist of several actions taken upon the master and the apprentice of the incident.
  3. An apprentice is declared to be a scale that will perform the command once the specified incident happens on the master scale.

 

Such incidents are called abstract incidents, because they are declared without specifying their master scale explicitly. Rather this scale is referred to using the somebody keyword in the incident’s declaration.

 

T

here is another variation of incidents – concrete incidents. These incidents are declared explicitly to happen when the concrete scale changes its color. Such incidents have no apprentices. Instead, they have aftermaths.

Aftermath is also the sequence of actions that will take place once the concrete incident happens.

 

T

he important thing to note: if a color is assigned to a scale, but the scale remains the same (in case the new color happened to be equal to the old one), no incident is generated. Remember, everything within one FVM’s cycle is an atomic operation !

 

For now, you shouldn’t be scared by the complexity of incident declarations. You will learn about incidents in the second part of the book.

 

 

 

 

 

 

Part II

 

FiPL – the Fish Programming Language

 

 

Some preliminary notes:

 

Fish Programming Language is case sensitive, you should use keywords and identifiers remembering their letters’ case. The only exception is the names of scales and tails. Thus, S1 and s1 denotes the same scale.

 

You can comment your programs using the old C-style syntax. Everything within /* and */ is regarded as a comment.

 

 

Chapter 4

Assignments and the Like

 

Assignments are the basic constructions of FiPL that are used to assign colors to scales in the FCW and to declare all other language entities.

 

There are two kinds of assignments: so called is-assignment and are-assignment.

Is-assignment is used to assign a color value to a single scale or a tail as well as to declare a single scale to be an apprentice, flip-flop and haphazard.

 Is-assignment is also used to assign a value to a horde, and to declare incident, aftermath and command.

For example is-assignments are used in the following cases:

 

S1 is (1,2,3);

S2 is flip-flop of (1,1,1) and (2,2,2);

I is incident when somebody becomes (R,G,B);

MyHorde is haphazard;

 

Are-assignment is used to declare a group of scales to be a horde, or a group of buddies:

 

S1,S2,S3 are buddies,

S30,S40,S50 are horde MyHorde;

 

Like keyword is used to assign to a scale the same color as of the other scale ot tail:

 

S1 is like S2;

S1 is like T5;

MyHorde is like t0;

S50 is flip-flop of like S1 and like S2;

S40 is like S1 + like T1;

 

Remember to use the like word always when you refer to a color of a scale or a tail rather than to an explicitly specified color. The like word is also used when referring to a master or an apprentice. You will learn about it later.

 

 

 

 

Chapter 5

Buddies, Horde and All the Fish

 

Constructions discussed in this chapter deal with declaring and organizing groups of scales.

 

A

 most convenient way to refer to a number of scales is by organizing them into a group called horde:

 

S20,S25,S47 are horde DreamTeam;

 

Then, these scales can be referred to by their horde’s name:

 

DreamTeam is RED;

DreamTeam is flip-flop of like T5 and TAN;

DreamTeam is haphazard;

DreamTeam is apprentice of s0 doing Command1 after Incident1;

 

Note, that all the operations allowed with a single scale are also allowed with a horde.

Horde name cannot appear in the right part of an assignment well.

 

D

 

efining several scales to be buddies will make them to share the same color and the same behaviour. Any change of one of the buddies group member will immediately take effect on all other members of the group.

 

Thus, if we declare

 

S10,S20,S30,S40,S50 are buddies;

 

after the following assignment

 

S20 is MAROON;

 

S10, S30, S40 and S50 will be immediately colored in MAROON.

 

If we will declare one of this buddies group member as haphazard, all other members of the group will become haphazards, meaning all of them will have different (note!) random color.

Defining one of the buddies group as a flip-flop will turn all its buddies into flip-flops.

However, declaring one of the buddies group member as an apprentice will not make other members apprentices too.

 

Note, that if two sets of buddies are not intersected. Following examples will make this clear:

First example – groups are not intersected.

 

s0,s1,s2 are friends;
s2,s3,s4 are friends;
s1 is RED; /* s0,s1,s2 becomes RED */

Second example – coloring of a buddy that is not common to both groups.


s0,s1,s2 are friends;
s2,s3,s4 are friends;
s1 is RED; /* s0,s1,s2 become RED */
s3 is YELLOW; /* then, immediately s2,s3 and s4 becomes YELLOW */

Third example – coloring of a buddy that is common for both groups.


s0,s1,s2 are friends;
s2,s3,s4 are friends;
s1 is RED; /* s0,s1,s2 becomes RED */
s2 is (1,2,3); /* immediately all of the scales become (1,2,3) */

 

 

A

ll the fish keyword simply denotes all the FCW without tails, i.e. all scales. Thus the all-the-fish assignment will be applied to all the scales of FCW.

 

all the fish is like S0;

A is aftermath of I as follows [

all the fish will be BLACK;

]

all the fish is flip-flop of (1,1,1) and (2,2,2);

all the fish is apprentice of s0 doing Command1 after Incident1;

 

All the operations allowed with a single scale or horde also allowed with all the fish.

 

The simplest way to color all FCW with random colors is to issue the command:

 

all the fish is haphazard;

 

Note, that all the fish construction can never be used in the right part of an assignment. For example, “S0 is like all the fish;” operation is illegal, because one cannot guarantee that all the scales of the fish will have the same color.

 

You should remember that commands using all the fish construction are tend to be time and CPU consuming.

 

 

 


Chapter 6

Scale and Tail color arithmetic

 

S

cale and Tail identifiers are used in the following manner:

Scale is denoted by either capital or lowercase S followed by this scale’s number, e.g. S0,S1,S2, etc.

Tail is denoted by either capital or lowercase T followed by this tail’s number, i.e. T1,T2,T3,T4,T5.

Note, that the numeration of scales begins with 0, while the numeration of tails begins with 1.

 

 

F

iPL has a plethora of predefined colors that can be used in the language constructions. The keywords for predefined colors are spelled in upper case with underscore separating words in a name of the color. For example:

ALICE_BLUE, DARK_GOLDEN_ROD, HONEY_DEW etc.

For a full list of predefined colors see Appendix B.

 

Otherwise, the arbitrary color can be defined with the following syntax:

(R,G,B)

where R, G and B are numbers within the interval 0-255 denoting the Red, Blue and Green components of the color accordingly.

 

Thus, an assignment of a color to a scale or tale is performed like this:

 

S1 is (233,150,122);

T1 is (255,239,213);

 

Which is equal to

 

S1 is DARK_SALMON;

T1 is PAPAYA_WHIP;

 

 

T

here are only two operations allowed on the scales’ color: addition and subtraction. When an operation is performed, the R,G and B components of a scale(tail) are added(subtracted) one by one.

The operations can be used as shown in the following examples:

 

S0 is (10,20,30);

S0 is like S0 + (35,47,64);

S0 is like T1 (45,87,90);

T5 is SANDY_BROWN + (100,100,100);

T2 is like S50 + TORQUISE;

S45 is SPRING_GREEN PEACH_PUFF;

 

If the resulting color exceeds its limits, the value of it becomes 0 – if less than zero, 255 – if greater than 255.

 

Note the following limitations of the arithmetic expressions:

The syntax allows only two terms to be used in an arithmetic operation.

The arithmetic expression can be used only as a single assignment (as in the examples above). It cannot be used, for example, in the flip-flop declaration.

 

These limitations are introduced intentionally to keep the language as simple as possible.

 

 

Chapter 7

Flip-Flops and Haphazards

 

F

lip-flop is a scale that will periodically switch its color at every cycle. The switch will be performed between two colors specified in the flip-flop’s declaring statement. For example:

 

S1 is flip-flop of FUCHSIA and TURQUOISE;

S10 is flip-flop of S11 and T5;

Horde1 is flip-flop of S50 and (100,100,100);

 

In the last example all members of horde Horde1 will simultaneously switch their colors.

 

Flip-flops are important means for generating incidents. They may serve as a clock triggering incidents on each cycle of FVM.

 

Stopping a flip-flop is simple – just assign some color to it.

 

 

A

 scale declared as a haphazard will get randomly chosen color.

 

For example:

 

S5 is haphazard;

Horde2 is haphazard;

 


Chapter 8

Incidents and Aftermaths

 

Incidents, Aftermaths, Commands and Apprentices together form the most important FiPL construction. They are the driving force under the incidental programming. These concepts should be understood thoroughly in order to program in FiPL.

In this chapter you will learn about the concrete incidents and aftermaths, in the next chapter you will learn about the abstract incidents, commands and apprentices.

 

I

ncident is the basic concept of the FVM lifecycle, as you should already know from the first Part. It happens always when any scale’s color changes. Thus, at a single stage many incidents may happen simultaneously. However, not all of them will be treated. To treat an incident one should declare the aftermath or command of this incident, that is the actions that will take place after the incident occurs. Master of an incident is a scale that causes this incident.

Incidents are divided into concrete and abstract incidents.

Concrete incident is the incident explicitly specifying its master. For example:

 

S0SpringGreen is incident when S0 becomes SPRING_GREEN;

 

Here S0 is a master if this incident. The incident itself occurs once S0 gets the SPRING_GREEN color.

 

 

A

s was said, for an incident to have a meaning is to declare an aftermath (or a command) of it, i.e. the set of actions that will take place once this incident occurs.

 

Let’s consider the S0SpringGreen incident declared above. Thus, the following aftermath can be declared:

 

WhiteBlack is aftermath of S0SpringGreen as follows [

     S1 will be WHITE;

     S2 will be BLACK;

]

 

When S0SpringGreen occurs (i.e. S0 becomes SPRING_GREEN) S1 and S2 will be colored to WHITE and BLACK accordingly without any conditions.

 

One incident can have only one aftermath. This is because several aftermaths of a concrete incident have no meaning, and always can be united together. If one declares several aftermaths for one incident, only one of them will be executed. The choice of an aftermath to execute in this case is undefined.

 

In the body of an aftermath one can refer to the master of the incident using the master keyword:

 

LikeMaster is aftermath of S0SpringGreen as follows [

     S10 is like master;

]

 

Here, s10 will be colored as the master of the S0SpringGreen incident – into SPRING_GREEN color.

 

Master can as well be used in the left side of an assignment (or both) like this:

 

LikeMaster is aftermath of S0SpringGreen as follows [

     master is flip-flop of like master and RED;

]

 

Do not forget to use the like keyword when referring to a master.

 


Chapter 9

Abstract Incidents, Commands, Masters and Apprentices

 

There is an essential difference between aftermath and command. If aftermath’s actions occur each time after the incident, the command to be executed requires an apprentice to be declared for the master of this incident.

 

T

he notion of command involves both master and apprentice roles. In this case an incident declared abstract, using the somebody keyword instead of specifying the master scale. For example:

 

MediumOrchid is incident when somebody becomes MEDIUM_ORCHID;

 

That means, any scale becoming MEDIUM_ORCHID will produce the MediumOrchid incident, but only those having apprentices will be able to issue a command. For example:

 

BeLikeYourMaster is command as follows [

     apprentice will be like master;

]

 

Note, that the command itself is not related to any incident ! The declaration of apprentice will connect both incident and command together. For example:

 

S50 is apprentice of S49 doing BeLikeYourMaster after MediumOrchid;

 

This statement literally means: when S49 becomes MEDIUM_ORCHID it will issue the BeLikeYourMaster command for S50, then S50 becomes MEDIUM_ORCHID (like master, as the command says).

 

T

he important thing to mention here is that the apprentice keyword can be used inside the command declaration to refer to the scale being an apprentice during this command execution. Again, as in the aftermath’s case the master keyword refers to a scale that is the master of this incident, and both of them can appear on both sides of an assignment.

 

 

 

N

esting in the body of aftermath and command is possible and mostly welcomed.

For example:

 

Nested1 is aftermath of I1 as follows [

     Nested2 is aftermath of I2 as follows [

          S50 is YELLOW;

          I3 is incident when S50 becomes YELLOW;

          Nested3 is aftermath of I3 as follows [

              S50 is WHITE;

]

]

     S2 is BLACK;

]

 

In this case, Nested2 aftermath will be assigned only in case incident I1 occurs, and, accordingly,  Nested3 aftermath will be assigned only in case incident I2 occurs after incident I1. Nested3 aftermath’s body will be executed only in case incident I1, I2 and I3 all eventually occur in this order.

 

 

 


Chapter 10

Thanks For All the Fish

 

This chapter is very short. Here you will learn the last and the simplest operator of FiPL: thanks for all the fish.

This operator, once encountered, will completely stop the Fish Virtual Machine.

Its usage may become clearer from the following example:

 

S1 is flip-flop of BLACK and WHITE;

/* s1 server as a clock */

BlackEvent is incident when S1 becomes BLACK;

Cycle1 is aftermath of BlackEvent as follows [

     S50 is haphazard; /* change s50’s color */

]

WhiteEvent is incident when S1 becomes WHITE;

Cycle2 is aftermath of WhiteEvent as follows [

     S50 is haphazard; /* change s50’s color again */

]

TomatoEvent is incident when S50 becomes TOMATO;

EndProgram is aftermath of TomatoEvent as follows [

     thanks for all the fish; /* stop the FVM */

]

 

Here, the FVM will stop once s50 eventually becomes TOMATO.

 

 

 


Chapter 11

Examples

 

To wet the reader’s appetite we will look at some simple examples in this chapter.

 

L

et us start from the simplest example. How one can usually start a program ? Surely, you already know the answer: by issuing an incident starting it all.

 

Start is incident when S0 becomes BLACK;

Program is aftermath of Start as follows [

     /* here your assignments go */   

]

S0 is BLACK; /* start the program ! */

 

N

ow, we will take look at two examples of an artificial flip-flop, that are constructed without using the flip-flop keyword.

 

/* Good example */

 

s10 is (1,1,1);

Inc1 is incident when s10 becomes (1,1,1);

Aft1 is aftermath of Inc1 as follows [

     s10 is (2,2,2);

]

Inc2 is incident when s10 becomes (2,2,2);

Aft2 is aftermath of Inc2 as follows [

     s10 is (1,1,1);

]

 

Why this example is called “good” you will see from the following “bad” one:

 

/* Bad example */

 

s10 is (1,1,1);

Inc1 is incident when s10 becomes (1,1,1);

Aft1 is aftermath of Inc1 as follows [

     s10 is (2,2,2);

     Inc2 is incident when s10 becomes (2,2,2);

     Aft2 is aftermath of Inc2 as follows [

     s10 is (1,1,1);

     ]

 

]

What happens here, is that the Inc2 and Aft2 will be always reassigned each time the body of Aft1 is executed. While, this action will not harm the process and it will work exactly as in the first example, this reassignment is a waste of time.

 

I

n the following example, you will see how to organize a loop in FiPL:

 

/* Infinite loop of four steps */

s0 is (0,0,0);
Trigger1 is incident when s0 becomes (0,0,0);
Step1 is aftermath of Trigger1 as follows [
    s0 is (1,0,0);
]
Trigger2 is incident when s0 becomes (1,0,0);
Step2 is aftermath of Trigger2 as follows [
    s0 is (2,0,0);
]
Trigger3 is incident when s0 becomes (2,0,0);
Step3 is aftermath of Trigger3 as follows [
    s0 is (3,0,0);
]
Trigger4 is incident when s0 becomes (3,0,0);
Step4 is aftermath of Trigger4 as follows [
    s0 is (0,0,0); /* back to incident Trigger1 */
]

/*

   Same exapmle with nesting.

   Declarations will be replaced on each new loop.
*/

s0 is (0,0,0);
Trigger1 is incident when s0 becomes (0,0,0);
Step1 is aftermath of Trigger1 as follows [
    s0 is (1,0,0);
    Trigger2 is incident when s0 becomes (1,0,0);
    Step2 is aftermath of Trigger2 as follows [
        s0 is (2,0,0);
        Trigger3 is incident when s0 becomes (2,0,0);
        Step3 is aftermath of Trigger3 as follows [
            s0 is (3,0,0);
            Trigger4 is incident when s0 becomes (3,0,0);
            Step4 is aftermath of Trigger4 as follows [
               s0 is (0,0,0);

               /* back to incident Trigger1 */
            ]

        ]

     ]

 ]

As we mentioned in the previous example, the second variant, while looking more appealing, is more time consuming.
     

 

T

he next example will show the intricacies of using the master word in different nested contexts:

 

s10 is (1,1,1);
Inc1 is incident when s10 becomes (1,1,1);
Aft1 is aftermath of Inc1 as follows [
    s1 is like master;

    /* Here master is s10 */
    Inc2 is incident when s1 becomes like master;

    /* Master is also s10 */


    Aft2 is aftermath of Inc2 as follows [
        s5 is like master;

        /* In this context master is s1, since we are 
           inside the body of Aft2 */
    ]
]

 

 

T

wo following examples are doing the same: 6 iterations on a s1 (changing its color from (1,0,0) to (6,0,0). First example uses aftermath, while the second uses command.

 

/* Cycle example with aftermath */

 

s1 is (1,0,0);

s2 is flip-flop of (0,0,1) and (0,0,2);

/* s2 will trigger the incidents */

Cycle1Inc is incident when s2 becomes (0,0,1);

Cycle2Inc is incident when s2 becomes (0,0,2);

Cycle1 is aftermath of Cycle1Inc as follows [

     s1 is like s1 + (1,0,0); /* increment s1’s color */

]

Cycle2 is aftermath of Cycle2Inc as follows [

     s1 is like s1 + (1,0,0); /* increment s1’s color */

]

End is incident when s1 becomes (6,0,0);

/* we will go up to 6 loops */

Stop is aftermath of End as follows [

     s2 is BLACK; /* stop the flip-flop */

]

 

 

/* Cycle example with command - much better, because the command body has to be specified only once */

 

s1 is (1,0,0);

s2 is flip-flop of (0,0,1) and (0,0,2); /* a trigger */

Cycle is command as follows [

     /* Increment the apprentice’s color */

     apprentice is like apprentice + (1,0,0);

]

/* Declare incidents for both stages of flip-flop */

Inc1 is incident when somebody becomes (0,0,1);

Inc2 is incident when somebody becomes (0,0,2);

/* Declare s1 to be an apprentice of both incidents */

s1 is apprentice of s2 doing Cycle after Inc1;

s1 is apprentice of s2 doing Cycle after Inc2;

End is incident when s1 becomes (6,0,0);

Stop is aftermath of End as follows [

     s2 is BLACK; /* stop the flip-flop */

]

 

 

 

O

ur final example shows usage of all the fish as an apprentice.

 

 

s0 is RED;
Inc is incident when somebody becomes RED;
Comm is command as follows [
    apprentice is MAROON; /* all scales will be MAROON */
]
all the fish is apprentice of s0 doing Comm after Inc;

 

Appendix A

Glossary

 

Abstract incident. It happens when a scale (called master of the incident) changes its color. The incident is abstract if its master is declared implicitly using somebody keyword.

 

Aftermath. A set of actions that will be executed when a concrete incident happens. The assignments made in the body of aftermath will take effect on the next cycle.

 

All the fish. Denotes all the scales of FCW.

 

Apprentice. A scale that will react on an incident by performing a command issued by a master of the incident.

 

Are-assignment. This assignment is used to declare a group of scales to be buddies or horde.

 

Buddies. The group of scale that share their color. If one member of buddies group changes its color, all the group changes its color accordingly.

 

Command. A set of actions that will be executed when an abstract incident happens. The assignments made in the body of command will take effect on the next cycle. Command needs an apprentice of the master scale of the incident to be declared.

 

Concrete incident. It happens when a scale (called master of the incident) changes its color. The incident is concrete if its master is declared explicitly using the name of a concrete scale.

 

Cycle. A complete set of actions executed in the FVM as an atomic operation. The output of a cycle may be seen as the color state of all the scales and tails and the set of incidents that occurred during this cycle and will be executed in the beginning of the next cycle.

 

Fish Programming Language (FiPL). That’s what the second part of this book is all about.

 

Fish Colorful Workspace (FCW). The visible surface of the Fish that consists of 52 scales numbered from 0 to 51 and 5 tails numbered from 1 to 5.

 

Fish Virtual Machine (FVM). The machine behind the FCW that executes the FiPL operations cycle by cycle.

 

Fish Underwater Programming Environment (FUPE). This denotes all four components together: FIDE, FCW, FVM and FiPL.

 

Flip-flop. It is a scale whose color switches periodically between two values on each FVM cycle. The flip-flop will be stopped once the scale is assigned to any color.

 

Haphazard. It is a scale whose color is randomly chosen.

 

Horde. Horde denotes any group of scales that can be referred to later using the name of the horde.

 

Incident. Look at abstract incident, concrete incident.

 

Is-assignment. This assignment is used always when a single scale or tail is assigned.

 

Master. Master of an incident is a scale that issued this incident by changing its color.

 

Scale. The basic unit of FCW. Contains color value, and may have many characteristics such as to be a flip-flop, a haphazard, a master, an apprentice, a member of a horde, or a member of a buddies group.

 

Tail. The basic unit of FCW that can contain color value only. May be seen as a parallel to a general-purpose register of a familiar computer architecture.


 

 

Appendix B

Predefined colors

 

ALICE_BLUE, ANTIQUE_WHITE, AQUA, AQUAMARINE, AZURE, BEIGE, BISQUE, BLACK, BLANCHED_ALMOND, BLUE, BLUE_VIOLET, BROWN, BURLY_WOOD, CADET_BLUE, CHARTREUSE, CHOCOLATE, CORAL, CORNFLOWER_BLUE, CORNSILK, CRIMSON, CYAN, DARK_BLUE, DARK_CYAN, DARK_GOLDEN_ROD, DARK_GRAY, DARK_GREEN, DARK_KHAKI, DARK_MAGENTA, DARK_OLIVE_GREEN, DARK_ORANGE, DARK_ORCHID, DARK_RED, DARK_SALMON, DARK_SEA_GREEN, DARK_SLATE_BLUE, DARK_SLATE_GRAY, DARK_TURQUOISE, DARK_VIOLET, DEEP_PINK, DEEP_SKY_BLUE, DIM_GRAY, DODGER_BLUE, FIRE_BRICK, FLORAL_WHITE, FOREST_GREEN, FUCHSIA, GAINSBORO, GHOST_WHITE, GOLD, GOLDEN_ROD, GRAY, GREEN, GREEN_YELLOW, HONEY_DEW, HOT_PINK, INDIAN_RED, INDIGO, IVORY, KHAKI, LAVENDER, LAVENDER_BLUSH, LAWN_GREEN, LEMON_CHIFFON, LIGHT_BLUE, LIGHT_CORAL, LIGHT_CYAN, LIGHT_GOLDEN_ROD_YELLOW, LIGHT_GREY, LIGHT_GREEN, LIGHT_PINK, LIGHT_SALMON, LIGHT_SEA_GREEN, LIGHT_SKY_BLUE, LIGHT_SLATE_BLUE, LIGHT_SLATE_GRAY, LIGHT_STEEL_BLUE, LIGHT_YELLOW, LIME, LIME_GREEN, LINEN, MAGENTA, MAROON, MEDIUM_AQUA_MARINE, MEDIUM_BLUE, MEDIUM_ORCHID, MEDIUM_PURPLE, MEDIUM_SEA_GREEN, MEDIUM_SLATE_BLUE, MEDIUM_SPRING_GREEN, MEDIUM_TYRQUOISE, MEDIUM_VIOLET_RED, MIDNIGHT_BLUE, MINT_CREAM, MISTY_ROSE, MOCCASIN, NAVAJO_WHITE, NAVY, OLD_LACE, OLIVE, OLIVE_DRAB, ORANGE, ORANGE_RED, ORCHID, PALE_GOLDEN_ROD, PALE_GREEN, PALE_TURQUOISE, PALE_VIOLET_RED, PAPAYA_WHIP, PEACH_PUFF,  PERU, PINK, PLUM, POWDER_BLUE, PURPLE, RED, ROSY_BROWN, ROYAL_BLUE, SADDLE_BROWN, SALMON, SANDY_BROWN, SEA_GREEN, SEA_SHELL, SIENNA, SILVER, SKY_BLUE, SLATE_BLUE, SLATE_GRAY, SNOW, SPRING_GREEN, STEEL_BLUE, TAN, TEAL, THISTLE, TOMATO, TURQUOISE, VIOLET, VIOLET_RED, WHEAT, WHITE, WHITE_SMOKE, YELLOW, YELLOW_GREEN.

 

 


Colophon

 

Our cover image shows the Fish.