On Sat, 2006-11-25 at 16:45 -0800, llothar wrote:
> nateastle@[EMAIL PROTECTED]
schrieb:
>
> > For school I am writting a paper on Eiffel. One of the sections of the
> > papers is about function support and parameter passing. The question
> > that I have is: in a feature is it possible to have another feature as
> > a parameter (like ml)?
>
> Thats possible since ~2001 and called agent. Google for this keyword.
> They are not closures. They are function pointers, together with a
> pointer to the object and some saved parameters that are passed when
> called.
In other words, a closure, mostly. In particular, it is possible
to write curried functions that can be attached to global variables.
I think that saying "They are not closures" is not entirely adequate.
class
TEST
feature
adder(a: INTEGER): FUNCTION[TEST,TUPLE[INTEGER], INTEGER] is
-- a function that adds `a' to its argument
do
Result := agent add2(a, ?)
end
feature {TEST}
add2(x, y: INTEGER): INTEGER is
--
do
Result := x + y
end
end


|