Eine gute Antwort wäre:

Yes.

Re-entrant Code

An iterative version of the Fibonacci series is certainly possible, since an iterative version of any recursive program always is possible. It runs much faster than the recursive version. You may wish to figure out how to write this program.

As the Fibonacci code executes, there are several activations of the fib() method on the activation chain. Each activation is an individual entity that embodies a particular evaluation of the method with particular parameters. The activation for fib(5) is an individual entity that calls for the creation of other entities: the activation of fib(4) and fib(3).

An activation is like a software object. Each activation represents a distinct execution of its method (like each object is an distinct instance of its class). Each activation has its own values for its parameters (like each object has its own values for its instance variables).

Not all programming languages allow this. Old versions of FORTRAN and COBOL do not allow multiple activations of the same code.

Re-entrant code allows multiple, simultaneous activations which do not interfere with each other. Java and all modern languages are re-entrant.

Re-entrant code is important for more than just recursion. For example, the graphical objects displayed on the user interface of a modern computer system are all controlled by one set of methods. These methods are re-entrant, so that only one copy is needed no matter how many windows and icons are on the display.

FRAGE 20:

Are you using re-entrant code right now?

Inhaltsverzeichnis