Re: Closed agent arguments
Frederic Merizen <[email protected]>
| Newsgroups | gmane.comp.lang.eiffel.smalleiffel |
|---|---|
| Organization | LORIA |
| Message-ID | <[email protected]> |
Hi,
On Thursday 21 April 2005 16:25, Wolfgang Jansen wrote:
> class X creation make
>
> feature
> make is
> do
> n := 3
> func := agent run(n) -- closed_arg=5 at agent creation time
> n := 5
> func.call([]) -- uses new value of `n' for closed_arg
> end
>
> n: INTEGER
> func: PROCEDURE[ANY,TUPLE]
>
> run(i: INTEGER) is
> do
> print(i.out); print("%N")
> end
>
> end
>
> When running, the program prints 5 while one would
> expect 3 (and 3 is also the output if compiled by SE1.1).
> Is this a bug or a new language feature?
It must be a bug. A feature that makes your program behave differently from
the following one would be too bewildering to be useful.
class Y creation make
feature
make is
local
n: INTEGER
do
n := 3
func := agent run(n) -- closed_arg=3 at agent creation time
n := 5
func.call([]) -- uses new value of `n' for closed_arg
end
func: PROCEDURE[ANY,TUPLE]
run(i: INTEGER) is
do
print(i.out); print("%N")
end
end