5.5   Procedure Resolution

A procedure can only be called if it can be resolved from the point of insertion of the procedure call. Because duplicate procedure names are allowed in HDevelop, understanding the order of resolution is very important. The resolution order determines which procedure is used if several procedures of the same name exist. For example, the imported procedure xyz.hdvp takes priority over the local procedure xyz.hdvp.

Procedures are resolved based on their name only and not on the matching of the signature. If the resolved procedure has a different signature, such like different number and/or types of parameters, the call will be invalid.

A procedure call looks for a procedure of the given name in the following order:

  1. Imported procedures

    HDevelop looks for imported procedures (section “Procedure Locations”). Note that for several import statements that contain procedures of the same name, the last import call has priority.

  2. Context of the calling procedure

    If no imported procedure is found, the context of the calling procedure is significant for the procedure resolution. The context depends on the type of the calling procedure:

  3. External procedures

    HDevelop looks for external procedures (section “Procedure Locations”) in the following order:

    1. Session locations:

      hdevelop -external_proc_path:<path name(s)>
      

    2. Static user-defined locations
    3. Standard procedure path

The tool tip of a procedure call reveals the location of the resolved procedure.

Resolution Example

As an example, we look at a program with three local procedures. Two procedure directories are defined (disregarding the standard procedure path).

+ C:/Users/Public/
|
+--+ example.hdev
|  |
|  +--- main
|  +--- init
|  +--- compute_results
|
+--+ procedures/project/
|  |
|  +--- init.hdvp                public
|  +--- local.hdvp               private
|  +--- setup.hdvp               public
|  |
|  +--+ visualization.hdpl       library
|     |
|     +--- init                  private
|     +--- process               private
|     +--- setup                 public
|
+--+ procedures/common/
   |
   +--- config.hdvp              public

In procedure a call to resolves to

main init init (local procedure in example.hdev)
project/visualization.hdpl/setup init project/visualization.hdpl/init
common/config init project/init
main process -
project/visualization.hdpl/init process project/visualization.hdpl/process
compute_results local -
project/setup local project/local