Fields, access, and Final
A field is a typed member stored on an object or its class. Instance fields belong to each object; static fields belong to the class.
Declare and use fields
Section titled “Declare and use fields”Open /plot classes, choose the class, then add a field from a typed Variable. Field settings expose access, Static, Final, and reusable field Variable items. Obtain a field Variable to use the field as a Set Variable destination or input. For an instance field, hold the owning-class Variable when obtaining the field reference so its receiver is identified.
Create a PlayerStats instance class with a Number field points. In a method on that instance, This Object is its receiver. A Variable containing that object can expose the same field outside the method where access permits.
Visibility
Section titled “Visibility”| Access | Who may use it |
|---|---|
| Public | Compatible callers |
| Protected | Declaring class and subclasses |
| Private | Declaring class only |
Visibility also applies to expression field access. Inherited fields retain their declaration identity; choose unique names across the chain to avoid collisions.
Initialization
Section titled “Initialization”Fields can be unassigned. Reading an unassigned field reports an error. Use a constructor or explicit assignment to establish required state. Is Assigned/Variable Exists tests assignment, while ?? can provide a fallback without writing the field.
${private.stats.points}${private.stats.points ?? 0}These examples require a previously declared object Variable stats and an accessible compatible field. See expressions for type checks and fallback behavior.
Final fields
Section titled “Final fields”Final locks the field binding after its first assignment. Referenced contents may remain mutable. Save graphs preserve assignment state. Interface fields are public, static, and final.
Input passing uses the current Reference/Shallow Copy/Deep Copy model. Assigning from another Variable shares referenced contents by default, but later rebinding the source Variable does not rebind the field. Older descriptions of persistent source-binding links do not describe this model.
Removing a field
Section titled “Removing a field”Choose the field and Remove Field. This edits the draft. Fix every source reference before compiling. A successful new build omits removed fields from saved object graphs; a failed compile retains the previous successful program. Removing then recreating the same text name does not promise the original field identity.