Agent problems

Construction.png Not Ready for Review: This Page is Under Development!

The following feature expects as its formal argument an agent:

foo (f: FUNCTION [A, TUPLE [B], C]): C
      l_f: FUNCTION [A, TUPLE, C]
      l_f := f
      Result := l_f.item ([])

By giving its formal argument a type, a feature specifies what it expects of the actual arguments. Feature foo expects the passed agent to:

  • refer to a feature of a descendant of class A.
  • have at least one open argument. The type of it needs to be a descendant of class B.
  • refer to a feature with a return type that is a descendant of class C.

At the same time feature foo gives almost no guarantees about how it will use agent f. It calls the agent without passing any arguments. This is not detected by the type system but will certainly end in runtime failures. This is a very unfortunate situation. The Eiffel agent mechanism is quite verbose, the user has to type in a lot of typing information. At the same time the type system gives the programmer no safety.