previous contents index next
(..Table Part..) Contents Index (..Table Part..)

4.2.1 Assignments to Sites in SDL (SelfAssignment;)

SelfAssignment - Syntax:

Syntax: SelfAssignment

 

Perhaps you have - reading the headline of this paragraph - remembered that we have already shown a syntax which enables assignments to arbitrary cells of the retina, accessing them by their coordinates, in the chapter about RDL, and you wonder why we do not use that syntax here as well? Simply because we do not want to affect only those cells with certain coordinates, but all cells at the same time! In RDL it has been our aim to create once and forever an initial configuration. Therefore, it has been necessary to treat different cells in different ways; but running the simulation, the situation changes completely: Now all state changes on the retina must be done by the global mapping, what is realized by applying the local rule to all cells simultaneously. Since SCARLET is fortunately an highly abstract programming language, it is sufficient to write each assignment in a table only once for all cells.
 

This non existent cell, which all the assignment are made to, and by which actually every site of the retina could be meant, we will call "generic cell"; its syntactical name is SELF, so that we finally get the following syntax:

SELF = CellExpression ;

(As in former cases, the semicolon is not part of CellAssignment (compare to VarAssignment; ).

Note that in SDL CellExpression can also be a NeighbourIdentifier. In this case CellExpression is no longer constant but varies from cell to cell.

For this is an assignment, the register contents of SELF is left unchanged, when VOID is contents of the corresponding register of CellExpression.


 
Example 44:

For a two-dimensional retina, three neighbours left, right, center (the generic cell), and a state structure consisting of three integer registers num1, num2, num3 we could invent the following examples of assignments:

SELF = left;

SELF = {center.num1+1, VOID, VOID};

SELF = {VOID, right.num3, left.num2}; 

 

Finally it is again possible not to affect the whole state, but only single registers of the generic cell. According to what we have described several times before for similar situations (the most general case is found in 'Accessing Single Registers'), we first have to select the register of interest by adding its name to the cell's name separated from each other by a point. For a register with type INT e.g., we would get SELF.IntRegIdentifier; but since SELF contains no information, we omit it and type

IntRegIdentifier

for integer registers and

StringRegIdentifier

for string registers, instead.


Now it is very easy to complete the syntax, because these objects are treated again like normal variables of type INT or STRING. We get

StringRegIdentifier = StringExpression ;

or

IntRegIdentifier = IntExpression ;

respectively.


In case of an integer register we have the same short forms with the same meaning as for integer variables:

IntRegIdentifier IntAsgOp IntExpression ;

IntRegIdentifier ++ ; (Dekrement)
IntRegIdentifier - ; (Inkrement)




Example 45:

In example 44 instead of SELF = {center.num1+1, VOID, VOID}:

num1++;


previous contents index next
(..Table Part..) Contents Index (..Table Part..)