Tips and Pitfalls

Procedure Arguments


If a procedure has formal parameters, they should agree in both number and type in the procedure declaration and when the procedure is called. In particular, beware of short or char parameters in argument lists. An int may be passed as a parameter to a procedure expecting a SHORT integer on some machines, but this usage is not portable, and is not detected by the compiler. The compiler does not verify that a procedure is declared and used consistently. Do not use type coercion in procedure actual arguments. Such as:

call foobar (..., short (intvar), ...) 
In some cases, the coercion is not performed in passing the argument to the procedure. A particular problem is using a literal (quoted) character in the calling sequenct to a procedure expecting a char such as stridx(). Such a literal is converted into an integer constant. On some systems, it won't matter if the called procedure expects a long or short integer, but on some, it will result in the wrong value passed.


Generated with CERN WebMaker