chore: Removed unnecessary bold in titles
Signed-off-by: erick-alcachofa <erick@artichoke.dev>
This commit is contained in:
parent
d0599d374f
commit
e024c03134
@ -1,6 +1,6 @@
|
||||
# **The `artichoke` Programming Language: A Technical Overview**
|
||||
# The `artichoke` Programming Language: A Technical Overview
|
||||
|
||||
## **1. Introduction**
|
||||
## 1. Introduction
|
||||
|
||||
`artichoke` is a statically-typed, general-purpose programming language designed
|
||||
with an emphasis on performance, safety, and expressive syntax. It combines
|
||||
@ -10,9 +10,9 @@ overview of the language's features as defined by its core grammar.
|
||||
|
||||
Is highly inspired by C, C++, Rust, and mostly Zig.
|
||||
|
||||
## **2. Basic Syntax & Structure**
|
||||
## 2. Basic Syntax & Structure
|
||||
|
||||
### **Modules, Imports, and Aliases**
|
||||
### Modules, Imports, and Aliases
|
||||
|
||||
`artichoke` code is organized into modules. The `import` statement is used to bring
|
||||
symbols from other modules into the current scope.
|
||||
@ -29,7 +29,7 @@ using mem = std::memory;
|
||||
using FileHandle = std::fs::File;
|
||||
```
|
||||
|
||||
### **Comments**
|
||||
### Comments
|
||||
|
||||
The language uses C-style block comments.
|
||||
|
||||
@ -38,12 +38,12 @@ The language uses C-style block comments.
|
||||
comment. */
|
||||
```
|
||||
|
||||
## **3. The Type System**
|
||||
## 3. The Type System
|
||||
|
||||
`artichoke`'s type system is strong and static, with a rich set of features for
|
||||
defining complex data structures.
|
||||
|
||||
### **Type Qualifiers**
|
||||
### Type Qualifiers
|
||||
|
||||
Qualifiers modify the type to their immediate right, allowing for precise and
|
||||
complex type definitions.
|
||||
@ -59,7 +59,7 @@ complex type definitions.
|
||||
These qualifiers can be combined. For example, `*$?int` defines a **pointer to a
|
||||
mutable optional integer**.
|
||||
|
||||
### **Generics**
|
||||
### Generics
|
||||
|
||||
Generics allow for writing flexible, reusable code that can operate on multiple
|
||||
types. They are defined using `<typename T>`.
|
||||
@ -78,9 +78,9 @@ fn scale<typename T>(lhs: *Point<T>, rhs: T) -> Point {
|
||||
```
|
||||
|
||||
|
||||
## **4. Declarations**
|
||||
## 4. Declarations
|
||||
|
||||
### **Variables**
|
||||
### Variables
|
||||
|
||||
Variables are declared using the `let` (mutable) and `def` (immutable/constant)
|
||||
keywords.
|
||||
@ -96,7 +96,7 @@ let x: i32 = 10;
|
||||
def do_you_get_it = meaning_of_life();
|
||||
```
|
||||
|
||||
### **Structs**
|
||||
### Structs
|
||||
|
||||
Structs are composite data types that group together variables under one name.
|
||||
They support generics.
|
||||
@ -119,7 +119,7 @@ def top_left = Point<i32>{ 0, 10 };
|
||||
def top_right = Point<i32>{ x: 10, y: 10 };
|
||||
```
|
||||
|
||||
### **Enums (Tagged Unions)**
|
||||
### Enums (Tagged Unions)
|
||||
|
||||
Enums define a type that can be one of several different variants. Variants can
|
||||
optionally hold data.
|
||||
@ -144,7 +144,7 @@ def my_asset = AssetType::Texture;
|
||||
def success = Result<i32, string>::Ok(100);
|
||||
```
|
||||
|
||||
### **Functions**
|
||||
### Functions
|
||||
|
||||
Functions are defined with the fn keyword. The return type is specified after
|
||||
the parameter list with `->`.
|
||||
@ -155,7 +155,7 @@ fn meaning_of_life() -> i32 {
|
||||
}
|
||||
```
|
||||
|
||||
#### **Member Functions (`this` parameter)**
|
||||
#### Member Functions (`this` parameter)
|
||||
|
||||
If the first parameter of a function is declared with the `this` keyword, it can
|
||||
be called using "member function" syntax.
|
||||
@ -175,9 +175,9 @@ my_point.add(&other_point);
|
||||
add(&my_point, &other_point);
|
||||
```
|
||||
|
||||
## **5. Control Flow**
|
||||
## 5. Control Flow
|
||||
|
||||
### **`if`/`else` Statements**
|
||||
### `if`/`else` Statements
|
||||
|
||||
`artichoke` supports C-style `if`/`else` and `else if` chains. It also integrates a
|
||||
powerful unwrapping feature for handling `Result` and optional (`?`) types.
|
||||
@ -198,7 +198,7 @@ else |err| {
|
||||
}
|
||||
```
|
||||
|
||||
### **Loops**
|
||||
### Loops
|
||||
|
||||
The language provides a comprehensive set of looping constructs.
|
||||
|
||||
@ -211,7 +211,7 @@ The language provides a comprehensive set of looping constructs.
|
||||
* **`do-while` Loop:** Guarantees the body executes at least once.
|
||||
* **Infinite `loop`:** `loop { ... }`
|
||||
|
||||
#### **Loop Labels and Control**
|
||||
#### Loop Labels and Control
|
||||
|
||||
Loops can be labeled. The `break` and `continue` statements can optionally specify a
|
||||
label to control nested loops.
|
||||
@ -224,9 +224,9 @@ outer_loop := while (condition) {
|
||||
}
|
||||
```
|
||||
|
||||
## **6. Expressions and Operators**
|
||||
## 6. Expressions and Operators
|
||||
|
||||
### **Pointer and Member Access**
|
||||
### Pointer and Member Access
|
||||
|
||||
* **`&` (Address-of):** Gets a pointer to a variable.
|
||||
* **`*` (Dereference):** Accesses the value a pointer points to.
|
||||
@ -234,7 +234,7 @@ outer_loop := while (condition) {
|
||||
* **`->` (Pointer Member Access):** Dereferences a pointer and accesses a member
|
||||
(`p->x` is shorthand for `(*p).x`).
|
||||
|
||||
### **Slice Operators**
|
||||
### Slice Operators
|
||||
|
||||
Slices have a dedicated set of operators for manipulation.
|
||||
|
||||
@ -243,14 +243,14 @@ Slices have a dedicated set of operators for manipulation.
|
||||
* **`.#` (Length Access):** Gets the number of elements in the slice.
|
||||
* **`.[length]` (Slice from Pointer):** Creates a slice from a raw pointer and a length.
|
||||
|
||||
### **Assignment**
|
||||
### Assignment
|
||||
|
||||
The language supports simple (`=`) and compound assignment (`+=`, `*=`, etc.)
|
||||
operators.
|
||||
|
||||
## **7. Advanced Features**
|
||||
## 7. Advanced Features
|
||||
|
||||
### **Resource Management (`defer` and `errdefer`)**
|
||||
### Resource Management (`defer` and `errdefer`)
|
||||
|
||||
`artichoke` uses `defer` for deterministic resource management.
|
||||
|
||||
@ -268,7 +268,7 @@ errdefer {
|
||||
}
|
||||
```
|
||||
|
||||
### **Reflection (`.@`)**
|
||||
### Reflection (`.@`)
|
||||
|
||||
The language provides a compile-time reflection mechanism via the `.@` operator.
|
||||
It can be applied to values, types, and static members to query metadata.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user