622
|
1 #summary Notes on the semantic rules of elements in the D programming language
|
|
2
|
|
3 == Classes ==
|
|
4 * Inherits from Object (defined in module object) if no base class is specified.
|
|
5 * May inherit only from one class (single inheritance.)
|
|
6 * May inherit zero to any number of interfaces.
|
|
7 * All classes can be implicitly cast to object.Object.
|
|
8 * Methods are "virtual" by default.
|
|
9 * Is a reference type.
|
|
10 * Instances are allocated on the heap (or on the stack; see attribute 'scope'.)
|
|
11 * Every class has a ClassInfo (from module object.)
|
|
12 * Attributes:
|
|
13 * abstract: class can't be instantiated.
|
|
14 * final: disallows inheritance by other classes.
|
|
15 * scope: instances are allocated on the stack. Variable declarations of this class must be marked with the scope attribute.
|
|
16 * const, invariant: D2.0 feature. All declarations inside the class body are marked as const or invariant.
|
|
17 * deprecated: using the class is an error.
|
|
18 * Meaningless: auto, extern, override, static, synchronized.
|
|
19 == Structs ==
|
|
20 * 'align' attribute has only a meaning for and in structs.
|
|
21 * Can't inherit other structs.
|
|
22 * Is a value type.
|
|
23 == Interfaces ==
|
|
24 * Can't have fields (member variables.)
|
|
25 * Methods must be declared but not defined (i.e. no function body.)
|
|
26 * Can inherit other interfaces.
|
|
27 == Enums ==
|
|
28 * The base type must be integral and it defaults to int.
|
|
29 * Named enums have their own scopes.
|
|
30 * The members of an anonymous enum are inserted into the scope that surrounds the enum declaration.
|
|
31 == Functions ==
|
|
32 * Variable declarations may not shadow other variables in the surrounding scopes. E.g: `void f(){ int a; { int a;/* Error: shadows outer 'a'*/ } }`.
|
|
33 == Variables ==
|
|
34 * Declarations are default initialized to Type.init.
|
|
35 == Imports ==
|
|
36 * Private importing is the default.
|
|
37 == Labels ==
|
|
38 * They are stored in a separate symbol table.
|