-
Notifications
You must be signed in to change notification settings - Fork 0
Writing an attribute
The following action assigns a value to an instance’s attribute
running task.Time to completion = remaining duration
Assuming that the local class is Task with a numeric Priority attribute having a type that supports the ++ operator, the following is legal:
++Priority // increment the priority
Assuming Commanded heading is an attribute of the local class Aircraft you could do this:
Commanded heading = ^go this way //incoming parameter assigned to local attribute
You can set an attribute of multiple instances of the same class:
engines ..= /powered by/Engine
engines.Power setting = desired setting
Each instance of engines will assign the same value to its Power setting attribute. In the case of the empty set, there is no error and no values will be assigned.
For the Rectangle class with attributes X, Y, Length and Width you can do this:
l, w = /Rectangle.(Length, Width)
The left right ordering indicated on the RHS is preserved on the LHS.
Or if you define a type called Rect Size with components Length and Width you could do this:
rect = /R6/Rectangle(ID: some rectID)
rect? {
rsize::Rect Size = rect.(Length, Width)
l,w = rs.(Length, Width) //extract components
}
For this to work, the type Rect Size must provide an initialization operation that takes two values whose types that match the Length/Width types.
Looking at the class model, let’s say that Rectangle.ID is an identifier. This selection then can yield only zero or one instance. We assign the scalar variables only if the rect instance set variable is non-empty and therefore holds a single instance.
Copyright 2020, 2021, 2022, 2023, 2025 © Leon Starr under MIT Open Source License
- Why they are problematic
- Instance attribute creation values
- Boolean values
- Special values
- Enumerated values
- Action block
- Statement
- Single line action
- Multiple dependent actions on a single line
- An action spread across multiple lines
- A conditional group of single line actions
- Comments
- Finding instances
- Attribute access
- Creation and deletion
- Subclass migration
- Creating a table from a class
- Creating a table with a definition
- Converting a table into a class
- Set operations on tables
- Set comparisons on tables
- Join
- Rename
- Extend
- Aggregation
- Rank
- Image
- Input values
- Signatures and name doubling
- Output values
- Execution order
- Sequential execution
- Conditional execution
- Signals
- Scrall has no for_each action
- Iteration