2011年10月21日 星期五

Callability of procedures


A more useful concept is the converse of the static scope of the name of a procedure, which we refer to as the callability of the procedure. Callability of a procedure determines the procedures that it can call.


#NOTE:此處說明Pascal的函數呼叫是否可行
Algorithm to draw the static tree of a Pascal program:
1.  Draw the main() program as the root node of the tree.
2.  Identify all the procedures/functions directly defined in main()Draw them as child nodes of main() node.
3.  Repeatedly carry out step 2 for all the leaf nodes of the tree, until there are no more nested procedures in the program.
In the Pascal program presented earlier, the procedures read()compute() and print() are defined directly inmain(), and are its children. The procedure prompt() is defined within read(), and is its child. The procedures initialize() and transform() are defined within compute()and are its children. The procedure defaults() is defined within initialize(), and is its child. The static tree of the program is shown below.


沒有留言:

張貼留言