null

Description

null is the variable identifier for a special built-in variable of type address, which is implemented by Irie Pascal to make it easier to call certain external functions and procedures written in the C programming language.

In C, there is no special mechanism for passing variables by reference, instead the programmer must explicitly declare the formal parameter to be the address of a variable, and pass the address of a variable as the actual parameter when making the call.

In Pascal, there is a special mechanism (i.e. var parameters) for passing parameters by reference, the programmer would declare the formal parameter as a var parameter, but the call remains the same because the Pascal implementation will take take of the passing the address of the variable behind the scenes.

So when declaring in Pascal, an external function or procedure written in C, that passes variables by reference it is natural to use var parameters for the variables passed by reference. In most cases, this works great and Irie Pascal will take care of the details, however in the following special case there is a problem. Neither C not Pascal support optional parameters (at least not in the standard versions of these languages), however in C because addresses are being passed explicity, and an address is just a value, it is possible to pass special values to mean that the parameter was not passed. In C, the special value zero (called the null pointer) is usually used for this purpose. The problem is, if a parameter is declared as a var parameter in Pascal you can't pass a value like zero, and any variable you do pass will have a non-zero address. The solution is to pass the special variable null which has an address of zero.

Operating Systems: All
Standard Pascal: No