Difference between revisions of "Agent"

From Liberty Eiffel Wiki
Jump to navigation Jump to search
(Created page with "Agents are objects that allow to defer computation. (to be completed) == Inline agents == Inline agents are closures: they may access the arguments and local variables de...")
 
Line 10: Line 10:
   
 
The usage limits are:
 
The usage limits are:
* names must be unique (i.e. shadowing an outside variable is not allowed)
+
* names must be unique (i.e. shadowing an outside variable is not allowed)
* Result is not accessible to inline agents; one must use another local variable (rationale: if the agent is a function, what would Result refer to?)
+
* Result is not accessible to inline agents; one must use another local variable (rationale: if the agent is a function, what would Result refer to?)
* access is read-only: you cannot assign to an outside local variable (and, of course, to an argument, but that's standard Eiffel anyway)
+
* access is read-only: you cannot assign to an outside local variable (and, of course, to an argument, but that's standard Eiffel anyway)
   
 
The technical limits are:
 
The technical limits are:
* beware of automatically allocated pointers for outside local variables, especially if the GC is not used. There is no such problem for arguments since their value cannot change throughout the execution of the outside feature
+
* beware of automatically allocated pointers for outside local variables, especially if the GC is not used. There is no such problem for arguments since their value cannot change throughout the execution of the outside feature

Revision as of 15:56, 19 November 2013

Agents are objects that allow to defer computation.

(to be completed)


Inline agents

Inline agents are closures: they may access the arguments and local variables defined in their outside feature (called outside variables).

The usage limits are:

  • names must be unique (i.e. shadowing an outside variable is not allowed)
  • Result is not accessible to inline agents; one must use another local variable (rationale: if the agent is a function, what would Result refer to?)
  • access is read-only: you cannot assign to an outside local variable (and, of course, to an argument, but that's standard Eiffel anyway)

The technical limits are:

  • beware of automatically allocated pointers for outside local variables, especially if the GC is not used. There is no such problem for arguments since their value cannot change throughout the execution of the outside feature