nil在pascal表示空指针,相当与C中的null,都是指针类型的。
另外delphi中的null是Variant型的空值:
Null represents the null Variant.
Unit
System
Category
variant support routines
var Null: Variant;
Description
Use Null to indicate unknown or missing data. Null can be assigned to variables
in an application that must contain a null value. Assigning Null to a Variant
variable does not cause an error, and Null can be returned from any function
with a Variant return value.
Assigning Null to a variable of any type other than Variant causes either a
compile-time error or raises an EVariantError exception. For example, in the
following code the assignment of v, the Null Variant, to Variant q is
successful
whereas the conversion of Variant v, which is now Null, to the
integer return type of the Test function, raises an exception.
function Test(v: Variant): Integer;
var
q: Variant;
msg: string;
begin
q := v
{ this is ok, since q is a variant }
if VarIsNull(q) then
msg := 'q is a null variant'
else
msg := 'q is not a null variant';
ShowMessage(msg);
Result := v
{ this raises an exception!!!}
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Test(Null);
end;
Expressions involving Null always result in Null. Thus, Null is said to
損ropagate?through intrinsic functions that return Variant data types. If
any part of the expression evaluates to Null, the entire expression evaluates
to Null.