In FORTRAN programming, when a variable is passed as an actual argument to a procedure, and the procedure modifies the corresponding dummy argument, the variable itself gets modified, unlike C or the default argument-passing mechanism of Pascal. Changing the value of a dummy argument inside a procedure changes the actual variable that invoked it. FORTRAN constants are declared with the PARAMETER statement, Constants are useful when we want to make sure that some quantity would not change its value no matter what we do, and it’s a safety measure against a certain kind of programming errors. Compilers have many ways for implementing constants and most of them are largely influenced by the underlying OS and CPU. Constants can be implemented in various ways, Replacement during compilation of every occurrence of the constant with its value. If the constant is passed to another procedure, it is no longer protected. Another way to implement a variable is to store them in memory like ordinary variables, but making the associated memory area read only. This method insures that the protection against modification is propagated to called procedures. If modification of constants is possible, it defeats the original purpose of a programming safety measure, and turns constants into a programming trap.
0 comments:
Post a Comment