From b419a1c7c779d15c7e64e9991570b801f52bd0ae Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sun, 12 Jul 2026 07:55:13 -0400 Subject: [PATCH] Updated docs to new version --- content/docs/guide/attributes.mdx | 4 ++-- content/docs/guide/classes.mdx | 25 ++++++++++++++++++++++++ content/docs/guide/modules.mdx | 19 +++++++++++++++++- content/docs/guide/structs-enums.mdx | 22 ++++++++++----------- content/docs/guide/syntax-overview.mdx | 3 ++- content/docs/guide/types.mdx | 2 ++ content/docs/guide/variables.mdx | 27 ++++++++++++++++++-------- 7 files changed, 79 insertions(+), 23 deletions(-) diff --git a/content/docs/guide/attributes.mdx b/content/docs/guide/attributes.mdx index 5365448..da73375 100644 --- a/content/docs/guide/attributes.mdx +++ b/content/docs/guide/attributes.mdx @@ -15,8 +15,8 @@ Outer attributes apply to the next item: ```mist #[derive(Debug, Clone)] struct Point { - i32 x, - i32 y, + i32 x; + i32 y; } #[test] diff --git a/content/docs/guide/classes.mdx b/content/docs/guide/classes.mdx index 57cb07d..79c8bbb 100644 --- a/content/docs/guide/classes.mdx +++ b/content/docs/guide/classes.mdx @@ -33,6 +33,29 @@ class Player } ``` +### Virtual Methods + +The `virtual` keyword marks methods as dispatchable through the vtable, enabling polymorphic behavior: + +```mist +pub class Animal +{ + str& name; + + pub constructor(str& name) + { + self.name = name; + } + + pub virtual void speak(&self) + { + println!("..."); + } +} +``` + +When a method is marked `virtual`, it can be overridden in subclasses and will be dispatched dynamically at runtime through the vtable. Non-virtual methods are called statically. + ### Inheritance ```mist @@ -59,6 +82,8 @@ void speak(&self) override(Animal) } ``` +Methods marked `override` are automatically virtual if the parent method is virtual. The semantic analyzer validates that overridden methods match the parent's signature. + ### Implementations You can implement directly on the class body: diff --git a/content/docs/guide/modules.mdx b/content/docs/guide/modules.mdx index 0ea8036..4243cba 100644 --- a/content/docs/guide/modules.mdx +++ b/content/docs/guide/modules.mdx @@ -1,6 +1,6 @@ --- title: Modules & Imports -description: Module declarations, imports, re-exports, and module resolution rules. +description: Module declarations, imports, re-exports, include directives, and module resolution rules. icon: FolderTree --- @@ -18,6 +18,23 @@ use std::collections::HashMap; pub use my_module::MyType; ``` +### Include Directives + +Mist supports C-style include directives for importing external files and crates: + +```mist +// Global include (C-style) +#include + +// Use include (import from crate) +pub use my_crate::my_module; + +// Local include (import from relative path) +#include "my_local_module.mist" +``` + +Include directives allow you to bring in external code without using the module system, which is useful for C interop and local file organization. + ### Module Resolution Mist maps the module tree to Rust's module system: diff --git a/content/docs/guide/structs-enums.mdx b/content/docs/guide/structs-enums.mdx index 05922f3..0565d66 100644 --- a/content/docs/guide/structs-enums.mdx +++ b/content/docs/guide/structs-enums.mdx @@ -9,13 +9,13 @@ icon: Box ```mist pub struct Point { - i32 x, - i32 y, + i32 x; + i32 y; } pub struct Generic { - T value, + T value; } ``` @@ -24,8 +24,8 @@ Fields can be public or private: ```mist struct User { - pub str& name, - i32 age, // private + pub str& name; + i32 age; // private } ``` @@ -34,19 +34,19 @@ struct User ```mist pub enum Option { - Some(T), - None, + Some(T); + None; } pub enum Message { - Quit, - Move(i32, i32), - Write { str& content, i32 length }, + Quit; + Move(i32, i32); + Write { str& content; i32 length; }; } ``` Enum variants can be: - **Named** — `Variant` - **Tuple** — `Variant(T1, T2)` -- **Struct** — `Variant { T1 field1, T2 field2 }` +- **Struct** — `Variant { T1 field1; T2 field2; }` diff --git a/content/docs/guide/syntax-overview.mdx b/content/docs/guide/syntax-overview.mdx index 4dcad4d..a1da343 100644 --- a/content/docs/guide/syntax-overview.mdx +++ b/content/docs/guide/syntax-overview.mdx @@ -19,13 +19,14 @@ true // Boolean false // Boolean "hello" // String (1, true, "x") // Tuple +[1, 2, 3] // Array ``` ### Identifiers & Keywords Keywords are reserved and cannot be used as identifiers: -`if`, `else`, `fn`, `for`, `while`, `match`, `return`, `break`, `continue`, `struct`, `enum`, `class`, `trait`, `impl`, `use`, `pub`, `mut`, `let`, `true`, `false`, `dyn`, `loop`, `unsafe`, `override`, `const`, `type` +`if`, `else`, `fn`, `for`, `while`, `match`, `return`, `break`, `continue`, `struct`, `enum`, `class`, `trait`, `impl`, `use`, `pub`, `mut`, `let`, `true`, `false`, `dyn`, `loop`, `unsafe`, `override`, `const`, `type`, `virtual` Identifiers follow the pattern `[a-zA-Z_][a-zA-Z0-9_]*`. diff --git a/content/docs/guide/types.mdx b/content/docs/guide/types.mdx index 1e15a64..d631616 100644 --- a/content/docs/guide/types.mdx +++ b/content/docs/guide/types.mdx @@ -14,6 +14,8 @@ i32 'a& // Reference with lifetime i32 unsafe& // Const pointer i32 mut unsafe& // Mutable pointer (i32, bool) // Tuple type +i32[]& // Array type (static non-fixed size) +i32[10] // Array type (fixed size) bool fn(i32) // Function pointer type bool Fn(i32) // Closure trait (Fn) bool FnMut(i32) // Closure trait (FnMut) diff --git a/content/docs/guide/variables.mdx b/content/docs/guide/variables.mdx index e75148a..d1ebdbf 100644 --- a/content/docs/guide/variables.mdx +++ b/content/docs/guide/variables.mdx @@ -5,14 +5,15 @@ icon: Variable --- ```mist -let x = 42; // Type-inferred immutable -let mut y = 10; // Mutable variable -i32 z = 100; // Explicit type annotation -str& s = "hello"; // Typed string reference -bool b = true; // Typed boolean -f64 f = 3.14; // Typed float -let (a, b) = (1, "two"); // Destructuring -let (x, (y, z)) = (1, (2, 3)); // Nested destructuring +let x = 42; // Type-inferred immutable +let mut y = 10; // Mutable variable +i32 z = 100; // Explicit type annotation +str& s = "hello"; // Typed string reference +bool b = true; // Typed boolean +f64 f = 3.14; // Typed float +(i32, str&) as x, y = (1, "hello"); // Typed tuple destructuring +let (a, b) = (1, "two"); // Destructuring +let (x, (y, z)) = (1, (2, 3)); // Nested destructuring ``` Variable declarations follow either of two forms: @@ -22,6 +23,16 @@ let [= ]; [= ]; ``` +### Tuple Variable Declarations + +Tuple variables can be declared with explicit type annotations using `as`: + +```mist +(i32, bool) (x, y) as = (1, true); + +i32 a, b = (1, 2, 3); +``` + ### Const and Static ```mist