Name
Read Directive
Syntax
propertyName:Type... readGetter...;
Description
A property’s read directive tells Delphi how
to get the property’s value. The
Getter can be the name of a field or a
method in the class or in an ancestor class.
If the Getter is a field, the
field’s type must be the same as the property’s type. The
usual access rules apply, so the field cannot be a private field of
an ancestor class unless the ancestor class is in the same unit.
Typically, the field is a private field of the same class that
declares the property. The field can be an aggregate (record or
array), and the Getter must specify a
record member or array element (at a constant index) of the
appropriate type. Records and arrays can be nested.
If the Getter is a method, the method must
be a function whose return type is the same as the property type. The
method can be static or virtual, but it cannot be a dynamic method.
If the property is indexed or an array property, the
Getter must be a method. The first
parameter is the index value, which is an Integer.
Subsequent arguments are the array indices. The type of each
Getter argument must match the type of the
corresponding array index.
When the user reads the property value, Delphi gets the value from
the Getter field or by calling the
Getter method.
Tips and Tricks
If you use a
Getterfield, Delphi compiles all property references into direct field references, so there is no performance penalty for using a property instead of a field.A good programming ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access