Topic: APLX Help : Help on APL language : System Methods : ⎕STATE Property names and values
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕STATE Property names and values


Currently implemented for Internal classes only.

Syntax:

    objref ← objref.⎕STATE B
    objref ← ⎕STATE B           (Within user-defined method, same as ⎕THIS.⎕STATE)

The monadic system method ⎕STATE returns a nested matrix of two columns, containing the names of each property in the first column, and the current value of each property in the second. It takes a right argument (0 or 1) which indicates which properties should be included in the result. If the right argument is 0, only values which differ from the default value are included. If it is 1, all properties which have a defined value are included:

      ⎕CR 'Circle'
Circle {
    X←0
    Y←0
    COLOR←'Pale green'
    RADIUS←100

    ∇R←Area
     R←(○1)×RADIUS*2
    ∇
}

      C←⎕NEW Circle
      C.X←23
      C.Y←12
      C.⎕STATE 0
 X 23
 Y 12
 
      C.⎕STATE 1
 X              23
 Y              12
 COLOR  Pale green
 RADIUS        100
 
      ⎕DISPLAY C.⎕STATE 1
┌→──────────────────────┐
↓ ┌→┐                   │
│ │X│      23           │
│ └─┘                   │
│ ┌→┐                   │
│ │Y│      12           │
│ └─┘                   │
│ ┌→────┐  ┌→─────────┐ │
│ │COLOR│  │Pale green│ │
│ └─────┘  └──────────┘ │
│ ┌→─────┐              │
│ │RADIUS│ 100          │
│ └──────┘              │
└∊──────────────────────┘

This operation is known as serialization of an object. Note that, if any of the properties include a reference to another object, the state of that object will not be expanded (serialized) in the returned matrix. The operation is therefore a 'shallow' copy of the data.


Topic: APLX Help : Help on APL language : System Methods : ⎕STATE Property names and values
[ Previous | Next | Contents | Index | APL Home ]