annotate wiki/semantics.wiki @ 805:a3fab8b74a7d

Updated wiki pages. Added new page mercurial.wiki.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 08 Mar 2008 22:09:59 +0100
parents 19e08da86123
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
622
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
1 #summary Notes on the semantic rules of elements in the D programming language
805
a3fab8b74a7d Updated wiki pages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 622
diff changeset
2 == Type Rules ==
a3fab8b74a7d Updated wiki pages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 622
diff changeset
3 [http://dil.googlecode.com/files/typerules.html Tables] of type rules.
622
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
4
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
5 == Classes ==
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
6 * Inherits from Object (defined in module object) if no base class is specified.
805
a3fab8b74a7d Updated wiki pages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 622
diff changeset
7 * May inherit only from one class (single inheritance.)
622
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
8 * May inherit zero to any number of interfaces.
805
a3fab8b74a7d Updated wiki pages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 622
diff changeset
9 * The inheritance graph must not have any cycles.
622
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
10 * All classes can be implicitly cast to object.Object.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
11 * Methods are "virtual" by default.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
12 * Is a reference type.
805
a3fab8b74a7d Updated wiki pages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 622
diff changeset
13 * Instances are allocated on the heap (or on the stack; see attribute 'scope'.)
a3fab8b74a7d Updated wiki pages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 622
diff changeset
14 * Every class has a !ClassInfo (from module object.)
622
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
15 * Attributes:
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
16 * abstract: class can't be instantiated.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
17 * final: disallows inheritance by other classes.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
18 * scope: instances are allocated on the stack. Variable declarations of this class must be marked with the scope attribute.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
19 * const, invariant: D2.0 feature. All declarations inside the class body are marked as const or invariant.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
20 * deprecated: using the class is an error.
805
a3fab8b74a7d Updated wiki pages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 622
diff changeset
21 * static: if a nested class is static it cannot access variables in the surrounding scope.
a3fab8b74a7d Updated wiki pages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 622
diff changeset
22 * Meaningless: auto, extern, override, synchronized.
622
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
23 == Structs ==
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
24 * 'align' attribute has only a meaning for and in structs.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
25 * Can't inherit other structs.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
26 * Is a value type.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
27 == Interfaces ==
805
a3fab8b74a7d Updated wiki pages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 622
diff changeset
28 * Can't have fields (member variables.)
622
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
29 * Methods must be declared but not defined (i.e. no function body.)
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
30 * Can inherit other interfaces.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
31 == Enums ==
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
32 * The base type must be integral and it defaults to int.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
33 * Named enums have their own scopes.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
34 * The members of an anonymous enum are inserted into the scope that surrounds the enum declaration.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
35 == Functions ==
805
a3fab8b74a7d Updated wiki pages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 622
diff changeset
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
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
37 == Variables ==
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
38 * Declarations are default initialized to Type.init.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
39 == Imports ==
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
40 * Private importing is the default.
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
41 == Labels ==
19e08da86123 Added semantics.wiki.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
42 * They are stored in a separate symbol table.