feature
Feature indicator:
Features:
Characteristic declaration definition block
Compiler command;
Other feature indicators:
Other features:
Other feature declaration definition blocks
Other feature declaration definition block ELSE declaration definition block
feature:
Link feature
Alignature
Compiler instruction
Deprecated
Private
Package
protected
public
Export
Static
Final
Override
Abstract
Const
Auto
Other features:
Commissioning feature
Version feature
Declare definition block
Declare definition
{}
{Declaration definition}
AttributeSpecifier:
Attribute:
Attribute Decldefblock
Pragma;
AttributeELSespecifier:
AttributeElse:
AttributeElse Decldefblock
AttributeElse DecldefBlock Else DeclDefblock
Attribute:
LinkageAttribute
AlignAttribute
Pragma
Deprecated
Private
Package
protected
public
Export
Static
Final
Override
Abstract
Const
Auto
AttributeElse:
Debugattribute
Versionattribute
Decldefblock
Decldef
{}
{Decldefs}
Features use to modify one or more methods of declaration. The usual form is:
Attribute decaration; // affect this statement
Attribute: // affects all the declarations of the next '}'
Declaration;
Declaration;
...
Attribute / / affect all the declarations in the statement block
{
Declaration;
Declaration;
...
}
Declarations in an optional ELSE clause:
Attribute
Declaration;
Else
Declaration;
Attribute / / affect all the declarations in the statement block
{
Declaration;
Declaration;
...
}
Else
{
Declaration;
Declaration;
...
}
Link feature
Link feature:
Extern
Extern (Link Type)
Link Type:
C
Di
Windows
Pascal
LinkageAttribute:
Extern
Extern (LinkAgetYpe)
LinkageType:
C
Di
Windows
Pascal
D provides a way to call C functions and operating system API functions because it is necessary to compatibility with both.
The link type is case sensitive and can be extended (they are not keywords).
C and
D is the necessary, other meaning is defined by implementation.
Realize: For Win32 platform, you should support
WINDOWS and
Pascal.
Specify a C function call convention by the following manner:
EXTERN (C):
INT foo (); // Use C to call the foo () D call convention is:
EXTERN (D):
or:
EXTERN:
Windows API call agreement is:
Extern (Windows):
Void * Virtualalloc
Void * lpaddress,
Uint dwsize,
Uint FlalocationType,
Uint flprotect
);
Alignature
Alignature:
Align
Align (integer)
AlignAttribute: Align
Align (Integer)
Specifies how structural members are aligned. If only
Align, set it to the default value, that is, the same default alignment value as the corresponding C compiler.
The integer specifies the aligned value, and its behavior is the same as the corresponding C compiler uses non-default alignment values. If the value is 1, it means that it is not aligned; the member will be close together.
Waste Features We often labeled a feature in the library as discarding while still retaining it backwards. Such statements can be marked as discarded, which means that you can generate an error when you encounter the code that references this class declaration by setting the compiler option:
Deprecated
{
Void Oldfoo ();
}
Implementation: The compiler should have an option to specify whether it is discarded by compilation.
Protective features for protection
Private,
Package,
protected,
PUBLIC and
EXPORT.
Private means that only members within this class and in the module in this class can access protected members. Private members cannot be rewritten. Private module members are equivalent to the Static declaration in the C program.
Package extends the private access, so that members in the package can access members within the other modules located in the same package. If the package is nest, this rule is applied only to the innermost package.
Protected means that only members within this class or within the derived class or members within the module in this class can access protected members. protected cannot be used for module members.
Public means that any code in the executable can access this member.
EXPORT means that any code outside the executable can access this member. The meaning of export is also defined from the DLL.
Const feature
Const
The Const feature declares can be valued at compile time. E.g:
const Int foo = 7;
Const
{
Double bar = foo 6;
}
Override characteristics
Override
OVERRIDE features for virtual functions. This means that this function must be covered with the same name and parameters as in the base class. When the parameters of the member function of a base class, the Override feature can be used to capture errors. Such all derived classes will know that they must update their overlay functions.
Class foo
{
Int bar ();
INT ABC (INT X);
}
Class foo2: foo
{
Override
{
Int bar (char C); // error, no bar (char) in foo
INT ABC (INT X); // OK
}
}
Static characteristics
Static
Static features for functions and data. This means that this statement will not be applied to a particular instance of an object, and it is applied to the type of object. In other words, this means no
THIS reference. When used for other statements,
STATIC will be ignored.
Class foo
{
Static int bar () {Return 6;}
Int foobar () {return 7;}
}
...
Foo f = new foo;
FOO.BAR (); // Get 6
Foo.foobar (); // Error, no foo example
F.bar (); // Get 6
F.foobar (); // Get 7
The static function will never be virtual.
In the entire program, the static data has only one instance instead of each object.
Static is different from in C, which does not mean it in this document. You can use the Private feature to do this. E.g:
Module foo;
INT x = 3; // x is global
Private int y = 4; // Y is the STICCCCATIC in the Foo can be applied to construct functions and destructuring functions, so that the static constructor and the static destructor are obtained.
AUTO characteristics
Auto
AUTO features for local variables and class declarations. For class declarations, the AUTO feature created one
AUTO class. For partial declarations,
Auto implements RAII (resource gaining initialization) protocol. This means that it automatically calls its destructor when the AUTO reference is disengaged from the action domain. Even because the abnormality is thrown, the destructive function will be called, so AUTO is used to ensure cleaning.
Auto cannot be used for global, static data members or parameters modified with inout or OUT. The array of auto is illegal, and the function return value is not allowed to be Auto. If it is not an initialization, it is not allowed to assign AUTO. Note: If there is a mandatory requirement, these restrictions may be relaxed.