definetly did not vibe code 0.0.5-alpha0

This commit is contained in:
2026-05-27 07:08:36 +02:00
parent 7f5940fbe3
commit 877401cc9d
10 changed files with 256 additions and 133 deletions
+33 -24
View File
@@ -4,11 +4,11 @@ description: Directing execution with expression-based logic, pattern matching,
icon: Split
---
Control flow in Mist provides a bridge between C-style procedural logic and Rust's expression-oriented design. While many structures can return values, they follow a strict syntax for blocks and statements.
Control flow in Mist provides a bridge between C-style procedural logic and Rust's expression-oriented design. Blocks, if statements, while/for/loop loops, and match expressions all support statement bodies — meaning braces can be omitted for single-statement branches.
## Conditionals
The `if` statement evaluates a boolean expression. It supports multiple `else if` branches and an optional `else` block.
The `if` statement evaluates a boolean expression. Single-statement bodies don't need braces:
```mist
if (score > 50) {
@@ -18,11 +18,17 @@ if (score > 50) {
} else {
println!("Fail");
}
// Single-statement body (no braces needed)
if (is_active) println!("Running");
// Expression body (soft return)
var result = if (valid) "ok" else "err";
```
## Match
The `match` statement provides exhaustive pattern matching. Currently, every match arm requires a block `{}` following the `=>` operator.
The `match` statement provides exhaustive pattern matching with support for multiple patterns per arm via `|`:
```mist
match (task_state) {
@@ -43,54 +49,57 @@ match (task_state) {
## Loops
Mist supports both functional iteration and traditional low-level loop control.
### Loop
An infinite loop construct:
```mist
loop {
println!("forever");
if (done) break;
}
```
### C-Style For Loop
For manual iteration control, Mist supports the standard three-part `for` loop: initialization, condition, and post-iteration statement.
```mist
for (var mut i = 0; i < 10; i = i + 1;) {
for (var mut i = 0; i < 10; i++;)
println!("Index: {}", i);
}
```
### For-In Loop
The `for-in` loop iterates over collections or iterators using Mist's pattern matching system.
```mist
for (var item in collection) {
for (var item in collection)
process(item);
}
// Destructuring within the loop
for ((i32 x, i32 y) in coordinates) {
for ((i32 x, i32 y) in coordinates)
draw_point(x, y);
}
// Range iteration
for (var i in 0..10)
println!("{}", i);
```
### While Loop
The `while` loop continues execution as long as the parenthesized expression evaluates to `true`.
```mist
while (active) {
wait_for_event();
}
while (count > 0) process(count--);
```
## Jump Statements
Execution flow can be interrupted or redirected using standard jump keywords.
- **`return`**: Exits the current function, optionally passing back a value.
- **`break`**: Terminates the innermost looping construct.
- **`continue`**: Skips the remainder of the current loop iteration and proceeds to the next.
- **`continue`**: Skips the remainder of the current loop iteration.
## Key Characteristics
- **Pattern Integration**: Loops and match arms utilize Mist's pattern system, allowing for seamless data destructuring during iteration.
- **Explicit Scoping**: Match items currently require explicit blocks, ensuring clear boundaries for variable shadowing and local logic.
- **Familiar Iteration**: The inclusion of C-style `for` loops provides fine-grained control for performance-critical logic where simple iteration is insufficient.
- **Rust-Native Safety**: Despite the procedural syntax, these structures compile to safe Rust, maintaining exhaustive checking and memory safety.
- **Statement Bodies**: If, while, for, and loop branches can omit braces for single statements or expressions.
- **Soft Returns**: Expression bodies (without `;`) implicitly return their value.
- **Pattern Integration**: Loops and match arms utilize Mist's pattern system for data destructuring.
- **Multiple Patterns**: Match arms support `|` for matching multiple patterns.
+73 -30
View File
@@ -4,80 +4,123 @@ description: The building blocks of logic, from literals to complex postfix chai
icon: Binary
---
Expressions in Mist are the fundamental units that evaluate to a value. The syntax follows a clean **prefix → primary → postfix** chain, providing a predictable structure that maps closely to Rust's mental model.
Expressions in Mist are the fundamental units that evaluate to a value. The syntax follows a clean **prefix -> primary -> postfix** chain, providing a predictable structure that maps closely to Rust's mental model.
## Primary Expressions
Primary expressions are the starting point of any logic chain. These include literal values, paths to static members, or grouped expressions in tuples.
```mist
// Literals and paths
var x = 42;
var y = Math::PI;
// Tuples
var coordinates = (10, 20, 30);
```
## Postfix Operations
Postfix expressions allow you to build on a primary value. This includes calling functions, accessing fields, indexing arrays, or initializing structs.
Postfix expressions allow you to build on a primary value with field access, calls, indexing, type casting, error propagation, and mutation operators.
```mist
// Field access and method/function calls
var len = list.length();
// Struct initialization
var task = Task {
name: "Drafting",
priority: 1,
};
// Indexing and Macro calls
var first = items[0];
println!("Value: {}", first); // Macro call via '!'
println!("Value: {}", first);
```
### Increment & Decrement
```mist
var mut i = 0;
i++;
i--;
```
### Compound Assignments
```mist
i += 10;
i -= 5;
i *= 2;
i /= 3;
value &= mask;
flags |= 0x01;
```
### Type Casting
Use `as` to convert between compatible types:
```mist
var x = 42;
var y = x as f64;
```
### Try Operator
Propagate errors with the `?` postfix operator:
```mist
var content = fs::read_to_string(path)?;
```
### Range Operators
```mist
0..10 // exclusive range (0 to 9)
0..=10 // inclusive range (0 to 10)
```
### Arrays
Arrays are initialized with brackets, with an optional repeat notation:
```mist
var arr = [1, 2, 3];
var zeros = [0; 10]; // ten zeroes
```
## Prefix Operations
Prefixes modify the primary expression that follows them. Mist uses these for logical negation, dereferencing, and creating references.
Prefixes modify the primary expression that follows them.
```mist
var mut value = 10;
var ref = &value; // Reference
var mref = &mut value; // Mutable reference
var val = *ref; // Dereference
var is_false = !true; // Logical NOT
var ref = &value;
var mref = &mut value;
var val = *ref;
var is_false = !true;
var neg = -42;
```
## Binary Operations
Binary operations are applied as postfixes to an expression, following a `bin_op ~ expr` pattern. This supports all standard arithmetic, comparison, and logical operators.
```mist
var sum = 10 + 20;
var is_equal = (x == y);
var complex = (a + b) * (c / d);
```
## Operator Table
Mist supports the following binary operators for comparisons and arithmetic:
| Category | Operators |
| -------------- | -------------------------------- |
| **Arithmetic** | `+`, `-`, `*`, `/`, `%` |
| **Comparison** | `==`, `!=`, `<`, `>`, `<=`, `>=` |
| **Logical** | `&&`, `\|\|` |
| Category | Operators |
| -------------- | ---------------------------------------------------------------- |
| **Arithmetic** | `+`, `-`, `*`, `/`, `%` |
| **Comparison** | `==`, `!=`, `<`, `>`, `<=`, `>=` |
| **Logical** | `&&`, `||` |
| **Bitwise** | `<<`, `>>`, `&`, `\|`, `^` |
| **Range** | `..`, `..=` |
| **Assign** | `=`, `+=`, `-=`, `*=`, `/=`, `%=`, `&=`, `\|=`, `^=`, `<<=`, `>>=` |
## Key Characteristics
- **Predictable Chaining**: The `prefix* ~ primary ~ postfix*` grammar ensures that complex expressions are parsed consistently, whether you are dereferencing a function call or indexing a struct field.
- **Rust-Style References**: While the pointer syntax `type*` is used in declarations, expressions use `&` and `&mut` to create references, maintaining compatibility with Rust's borrow checker.
- **Macro Integration**: Macros are treated as a postfix operation (`!`), allowing them to be called on identifiers just like standard functions.
- **Unified Tuples**: Tuples are primary expressions, allowing them to be passed, returned, or destructured seamlessly within the expression tree.
- **Predictable Chaining**: The `prefix* ~ primary ~ postfix*` grammar ensures complex expressions are parsed consistently.
- **Rust-Style References**: Expressions use `&` and `&mut` to create references, maintaining borrow checker compatibility.
- **Macro Integration**: Macros use `!` as a postfix operation.
- **Type Casting**: `as Type` provides explicit type conversion at the expression level.
- **Error Propagation**: The `?` operator enables early returns for `Result`/`Option` types.
+15 -15
View File
@@ -11,8 +11,8 @@ In Mist, variables follow the language-wide `type name` convention. For local sc
Variables are declared using the `var` keyword for automatic type inference. Like Rust, variables are immutable by default.
```mist
var message = "Hello Mist"; // Inferred as str*
var count = 42; // Inferred as i32
var message = "Hello Mist";
var count = 42;
```
## Mutability
@@ -29,28 +29,28 @@ price = 14.99;
## Explicit Typing
While `var` handles inference, you can explicitly define the type before the identifier. This is often used for clarity in complex logic or when the specific numeric width (e.g., `u8` vs `i32`) matters.
```mist
u64 large_id = 1000234;
bool is_active = true;
```
## Pattern Destructuring
Because variable declarations are patterns, you can destructure tuples or structures directly. This keeps data extraction clean and avoids manual indexing.
## Arrays
```mist
// Destructuring a tuple into local variables
(i32, i32) (x, y) = get_coordinates();
var list = [1, 2, 3]; // Standard init
var zeros = [0; 10]; // Repeat notation: ten zeroes
```
// Using 'var' within a pattern for inference
## Pattern Destructuring
```mist
(i32, i32) (x, y) = get_coordinates();
(String, i32) (name, age) = get_user_info();
```
## Constants
Constants are immutable values that are evaluated at compile time. They require an explicit type and follow the `const` keyword.
Constants are immutable values evaluated at compile time with an explicit type.
```mist
const i32 MAX_RETRIES = 5;
@@ -59,7 +59,7 @@ const str* VERSION = "1.0.4";
## Key Characteristics
- **Predictable Order**: Whether using `var` or an explicit type, the name of the variable always follows the "source" of its data.
- **Safety First**: Immutability by default prevents accidental state changes, mapping directly to Rust's memory safety model.
- **Zero-Cost Inference**: Type inference is handled entirely at compile time, ensuring there is no runtime performance penalty.
- **Shadowing**: Mist supports variable shadowing, allowing you to reuse variable names within the same scope to transform data without changing mutability.
- **Predictable Order**: Whether using `var` or an explicit type, the name always follows the "source" of its data.
- **Safety First**: Immutability by default prevents accidental state changes.
- **Zero-Cost Inference**: Type inference is handled entirely at compile time.
- **Shadowing**: Mist supports variable shadowing within the same scope.