Specification
According to ISO/IEC 25436:2006(E) and newly added language constructs:
Syntax-based terms
Local variable is any of the following:
- an identifier declared in a Local_declarations part (of a feature body, including inline agents)
- predefined entity
Result
Formal argument:
- an identifier to represent information passed by callers
Actual argument:
- an expression in a particular call to the routine
Variable attribute is a feature declaration satisfying all of the following:
- there are no formal arguments
- there is a query mark (i.e. it has a type)
- there is no explicit value (i.e. it is not a constant)
- if there is a body, it is of Attribute kind
Constant attribute is a feature declaration satisfying all of the following:
- there are no formal arguments
- there is a query mark (i.e. it has a type)
- there is an explicit value
Collective terms
Variable is any of the following:
- a final name of a variable attribute
- local variable (including
Result
)
Read-only entity is any of the following:
- formal argument
- object test local
- cursor local (in Iteration_part of a loop)
- separate local (in Separate_instruction)
- constant attribute
Current
Entity is any of the following:
- variable
- read-only entity
Query is any of the following:
I.e. a query is a feature that has a type and can be used to get a value at run-time.
Semantics terms
Field:
- a value in a direct instance of a non-basic type, corresponding to an attribute
Example
class C feature
pi: REAL_32 = 3.14
double (x: LIST [INTEGER]): LIST [INTEGER]
local
r: ARRAYED_LIST [INTEGER]
do
create r.make (x.count)
across x as c loop
r.extend (c.item * 2)
end
Result := r
end
average_age: NATURAL
count: NATURAL
print_list (x: LIST [PERSON])
do
average_age := 0
count := 0
x.do_all (agent (p: PERSON)
do
if attached p.name as n then
io.put_string (n + ": " + p.age.out + "%N")
average_age := average_age + p.age
count := count + 1
end
end)
if count > 0 then
average_age := average_age // count
end
end
end
Syntax-based terms
Local variable: r
, Result
.
Object test local: n
.
Cursor local: c
.
Formal argument: x
, p
.
Actual argument: x.count
, 2
(this is an argument for multiplication), c.item * 2
, ": "
(in string concatenation), p.age.out
, "%N"
, n + ": " + p.age.out + "%N"
, p.age
, 1
, 0
, count
(in division).
Variable attribute: average_age
, count
.
Constant attribute: pi
.
Collective terms
Variable: r
, Result
, average_age
, count
.
Read-only entity: pi
, n
, c
, x
, p
.
Entity: pi
, r
, Result
, average_age
, count
, n
, c
, x
, p
.
Query: pi
, double
, average_age
, count
.