Skip to content

Commit 3360e92

Browse files
committed
docs: big update
1 parent 055842b commit 3360e92

47 files changed

Lines changed: 1460 additions & 3034 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@ Deep dives into the compiler's internals and tooling protocols.
2626
- **[LSP Protocol](LSP.md)**: Documentation for the Zen C Language Server integration.
2727
- **[Plugin System](PLUGINS.md)**: How to extend the compiler with custom plugins.
2828

29+
## Reference (16 chapters)
30+
31+
| # | Chapter | Description |
32+
|:---|:---|:---|
33+
| 1 | [Variables & Constants](reference/01-variables-constants.md) | let, types, mutability |
34+
| 2 | [Primitive Types](reference/02-primitive-types.md) | int, float, bool, char, etc. |
35+
| 3 | [Aggregate Types](reference/03-aggregate-types.md) | Arrays, slices, tuples |
36+
| 4 | [Functions & Lambdas](reference/04-functions-lambdas.md) | Functions, closures |
37+
| 5 | [Control Flow](reference/05-control-flow.md) | if, while, for, match |
38+
| 6 | [Operators](reference/06-operators.md) | Arithmetic, comparison, sugar operators |
39+
| 7 | [Printing & F-strings](reference/07-printing-interpolation.md) | Output, string interpolation |
40+
| 8 | [Memory & Lifetimes](reference/08-memory-management.md) | Ownership, borrowing |
41+
| 9 | [OOP](reference/09-oop.md) | Traits, impl blocks, methods |
42+
| 10 | [Generics](reference/10-generics.md) | Type-safe templates |
43+
| 11 | [Concurrency](reference/11-concurrency.md) | Stackless async/await |
44+
| 12 | [Advanced](reference/12-advanced.md) | Inline assembly, raw blocks |
45+
| 13 | [Interop](reference/13-interop.md) | C, C++, CUDA, Objective-C interop |
46+
| 14 | [Unit Testing](reference/14-unit-testing-framework.md) | test, assert, expect |
47+
| 15 | [Diagnostics](reference/15-diagnostics.md) | Compiler warnings, categories |
48+
| 16 | [MISRA Rules](reference/16-misra-rules.md) | Safety rules, Zen-specific checks |
49+
2950
## Related Resources
3051

3152
- **[zenc](https://github.com/zenc-lang/zenc)**: The core compiler source code.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

reference/03-aggregate-types.de.md

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,90 @@ let ints: int[SIZE] = [1, 2, 3, 4, 5];
1414
let zeros: [int; SIZE]; // Nullinitialisiert
1515
```
1616

17-
#### Tupel
18-
Mehrere Werte gruppieren, Elemente über den Index aufrufen.
17+
18+
19+
20+
#### Tuples
21+
22+
Mehrere Werte zu einem einzigen zusammengesetzten Wert gruppieren. Tupel unterstützen beliebige Stelligkeiten (2, 3, 4, … bis 10+), Verschachtelung, Mutation einzelner Felder und Destrukturierung.
23+
24+
**Grundlegende Verwendung**
25+
26+
```zc
27+
let pair = (1, "hello");
28+
let triple = (1, "hello", 3.14);
29+
let five = (1, 2, 3, 4, 5);
30+
let typed: (int, string, f64) = (1, "two", 3.0);
31+
```
32+
33+
**Feldzugriff**
34+
35+
Elemente werden positionell mit `.0`, `.1`, `.2` usw. oder über die rohen Strukturfeldnamen `.v0`, `.v1` zugegriffen:
36+
1937
```zc
20-
let pair = (1, "Hallo");
21-
let x = pair.0; // 1
22-
let s = pair.1; // "Hallo"
38+
let t = (1, "hello", 3.14);
39+
assert(t.0 == 1);
40+
assert(t.v1 == "hello");
2341
```
2442

2543
**Mehrere Rückgabewerte**
2644

2745
Funktionen können Tupel zurückgeben, um mehrere Ergebnisse zu liefern:
46+
2847
```zc
29-
fn addiere_und_subtrahiere(a: int, b: int) -> (int, int) {
30-
return (a + b, a - b);
48+
fn stats(data: int) -> (int, int) {
49+
return (data * 2, data + 1);
3150
}
32-
33-
let ergebnis = addiere_und_subtrahiere(3, 2);
34-
let summe = ergebnis.0; // 5
35-
let differenz = ergebnis.1; // 1
51+
let r = stats(5);
52+
assert(r.0 == 10);
53+
assert(r.1 == 6);
3654
```
3755

3856
**Destrukturierung**
3957

40-
Tupel können direkt in Variablen zerlegt werden:
4158
```zc
42-
let (summe, differenz) = addiere_und_subtrahiere(3, 2);
43-
// summe = 5, differenz = 1
59+
let (sum, diff) = add_and_subtract(3, 2);
60+
let (a: string, b: u8) = ("hello", 42);
61+
let (x, y: i32) = (1, 2);
4462
```
4563

46-
Typisierte Tupel-Destrukturierung ermöglicht explizite Typannotationen:
64+
**Verschachtelte Tupel**
65+
4766
```zc
48-
let (a: string, b: u8) = ("Hallo", 42);
49-
let (x, y: i32) = (1, 2); // Gemischt: x abgeleitet, y explizit
67+
let nested = ((1, 2), (3, 4));
68+
let inner = nested.v0;
69+
assert(inner.v0 == 1);
5070
```
5171

72+
**Mutation**
73+
74+
Einzelne Felder können neu zugewiesen werden:
75+
76+
```zc
77+
let t = (1, 2);
78+
t.v0 = 99;
79+
```
80+
81+
**Zeichenkettenvergleich**
82+
83+
Tupel mit `string`-Feldern müssen für den Vergleich `strcmp()` verwenden, nicht `==` (das einen Zeigervergleich auf `char*` durchführt):
84+
85+
```zc
86+
let t = (1, "hello");
87+
assert(strcmp(t.1, "hello") == 0);
88+
```
89+
90+
**Aufzählungstupel**
91+
92+
Aufzählungsvarianten können Tupeldaten tragen:
93+
94+
```zc
95+
enum Shape {
96+
Point, Line(int, int), Labeled(int, string, f64),
97+
}
98+
```
99+
100+
52101
#### Structs
53102
Datenstrukturen mit optionalen Bitfeldern.
54103
```zc

0 commit comments

Comments
 (0)