Functions as Procedural Abstractions

Using the structured programming approach, an initial solution to a problem statement can be expressed as a sequence of high-level steps. Subsequently, these high-level steps are iteratively decomposed into a sequence of low-level instructions. These high-level steps are therefore 'abstractions' of the set of low-level instructions. A function is similar. It represents a high-level step which can be decomposed into a sequence of low-level instructions. Thus, for example in the Robot programming exercise discussed earlier, the turn_right instruction may be viewed as procedural abstraction, which is decomposed into a sequence of three turnleft instructions...


BEGINNING-OF-PROGRAM
               DEFINE-NEW-INSTRUCTION turnright AS
                    BEGIN
                         turnleft;
                         turnleft;      
                         turnleft;
                    END
               BEGINNING-OF-EXECUTION
                    move;
                    turnleft;
                    move;
                    turnright;
                    pickbeeper;
                    turnoff;
               END-OF-EXECUTION
END-OF-PROGRAM 

Similarly, other high-level instructions created using the
DEFINE-NEW-INSTRUCTION keyword may be viewed as procedural
abstractions.



Back to Previous Page

Document:
Local Date:
Last Modified On: