I've seen the terms entity, variable, and argument used to describe things about Eiffel, that look quite similar to me, and I wanted to understand what is the intention behind using either term instead of the other.
Arguments — Some routines require some data in order to run. Imagine a fictitious feature foo (x, y: INTEGER; z: BOOLEAN)
. This routine takes 3 arguments: x
, y
, and z
. When you call the routine, you must give it three valid arguments, for instance foo(6, 92, False)
. These values we passed to the routine are called actual arguments, while the placeholders defined in the definition are called formal arguments.
I've read of object fields, which specify the place inside the object structure where values are stored (either references or expanded objects).
I think the only time I saw the term variables was for local variables, inside features.
And entity seems to be a generic term for denoting a data-container with a name, so local variables, arguments, and querys (features that return some data) are all examples of entities.
And in what category would Current
and Result
fall? Local variables?
Could someone help me with the terminology?
According to ISO/IEC 25436:2006(E) and newly added language constructs:
Local variable is any of the following:
Result
Formal argument:
Actual argument:
Variable attribute is a feature declaration satisfying all of the following:
Constant attribute is a feature declaration satisfying all of the following:
Variable is any of the following:
Result
)Read-only entity is any of the following:
Current
Entity is any of the following:
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.
Field:
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
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
.
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
.