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