Name
Property Keyword
Syntax
propertyName
:Type
readGetter
writeSetter
; propertyName
:Type
readGetter
writeSetter
indexConstant
defaultConstant
storedStored
; propertyName
[Index
:IndexType
]:BaseType
readGetter
writeSetter
; default; propertyName
; propertyName
:Type
; // in dispinterface declarations only propertyName
:Type
readonly; propertyName
:Type
writeonly; propertyName
:Type
readGetter
implementsInterfaces
...;
Description
The property
keyword begins a property declaration
in a class
, interface
, or
dispinterface
declaration. A property can be
invoked from an object or interface reference using the same syntax
as a field, but you can use a method to implement access to the
property. This gives you the best of both worlds: convenient syntax
and flexible semantics, without sacrificing
performance.
In a dispinterface
declaration, a property can be
declared as readonly
or
writeonly
. The default (if both these directives
are omitted) is read and write access.
A property can also provide the implementation of one or more
interfaces. See the implements
keyword for more
information about this use of
properties.
Tips and Tricks
Delphi lets you declare default and stored values for any property, but these directives are meaningful only for published properties. The compiler generates RTTI for the published property, including the values of the
default
andstored
directives. These directives have no other impact on the language or the compiler, but the IDE reads the RTTI to ...
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.