added blog and improved docs
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
---
|
||||
title: Mist 0.3.1-alpha.0 is released, huge changes
|
||||
author: Klesti Selimaj
|
||||
date: 2026-06-10
|
||||
---
|
||||
|
||||
## OOP / Inheritance
|
||||
Inheritance is now fully supported, meaning you can change functions, however changes could still be made, and it's not fully robust.
|
||||
|
||||
The OOP model is pretty simple, and clever, it's type safe, meaning that function signatures are checked.
|
||||
|
||||
```mist
|
||||
pub class Animal {
|
||||
pub name String;
|
||||
|
||||
constructor() {
|
||||
self.name = "Rex".to_string();
|
||||
}
|
||||
|
||||
pub fn speak(*self) {
|
||||
println!("Unknown");
|
||||
}
|
||||
|
||||
pub fn legs(*self) {
|
||||
println!("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
pub class Dog : Animal {
|
||||
constructor() {
|
||||
super -> Super::new();
|
||||
}
|
||||
|
||||
pub override fn speak(*self) {
|
||||
println!("Woof!");
|
||||
}
|
||||
|
||||
// Explicit override is useful for super inheritance
|
||||
pub override(Animal) fn legs(*self) {
|
||||
println!("4 legs");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In the backend, it generates a V table, which is then indexed and replaced statically, meaning it's close to 0 cost abstractions.
|
||||
|
||||
## Syntax rewrite
|
||||
|
||||
The syntax now uses `type name` and is more similar to go than C, however the control flow is still C-like, and i will be refactoring that as well.
|
||||
```
|
||||
let x = 10; // inference
|
||||
let x *str = "hello Mist";
|
||||
```
|
||||
|
||||
Along with this, many bugs are fixed.
|
||||
|
||||
## Module system
|
||||
`pub mod my_mod;` still exists, but it's not needed at all, the module system reads your file structure and automatically adjusts parents.
|
||||
@@ -71,6 +71,10 @@ pub class Animal {
|
||||
pub fn speak(*self) {
|
||||
println!("Unknown");
|
||||
}
|
||||
|
||||
pub fn legs(*self) {
|
||||
println!("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
pub class Dog : Animal {
|
||||
@@ -81,6 +85,11 @@ pub class Dog : Animal {
|
||||
pub override fn speak(*self) {
|
||||
println!("Woof!");
|
||||
}
|
||||
|
||||
// Explicit override is useful for super inheritance
|
||||
pub override(Animal) fn legs(*self) {
|
||||
println!("4 legs");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -8,19 +8,7 @@ Mist organizes code through a file-system based module system with explicit path
|
||||
|
||||
## The Module System
|
||||
|
||||
Each `.mist` file in `src/` corresponds to a module. The module tree mirrors the file hierarchy. Directories can be declared as submodules using `mod`.
|
||||
|
||||
### File-Based Modules
|
||||
|
||||
The file `src/main.mist` is the crate root. Other files are discovered through `mod` declarations or by name.
|
||||
|
||||
### Declaring Submodules
|
||||
|
||||
```mist
|
||||
// src/main.mist
|
||||
mod network;
|
||||
mod database;
|
||||
```
|
||||
Each `.mist` file in `src/` corresponds to a module. and a `directory/package.mist` is a package like mod.rs, packages don't need `package.mist` to be functional, as long as a `.mist` file exists it will map it to pacakge_name::file_name.
|
||||
|
||||
## Imports
|
||||
|
||||
@@ -65,17 +53,17 @@ my-project/
|
||||
├── Cargo.toml
|
||||
├── src/
|
||||
│ ├── main.mist
|
||||
│ ├── lib/
|
||||
│ │ ├── parser.mist
|
||||
│ │ └── helper.rs
|
||||
│ └── _header.rs
|
||||
│ ├── my_api/
|
||||
│ │ ├── package.mist
|
||||
│ │ ├── methods.mist
|
||||
│ │ └── utils.mist
|
||||
└── .mist/
|
||||
└── src/
|
||||
├── main.rs # transpiled output
|
||||
├── lib/
|
||||
│ ├── parser.rs
|
||||
│ └── helper.rs
|
||||
└── _header.rs
|
||||
├── main.rs
|
||||
└── my_api/
|
||||
├── mod.rs
|
||||
├── methods.rs
|
||||
└── utils.rs
|
||||
```
|
||||
|
||||
The `.mist/src/` directory contains the transpiled Rust output. `_header.rs` is a special file that provides IDE support for Rust Analyzer.
|
||||
The `.mist/src/` directory contains the transpiled Rust output.
|
||||
|
||||
Reference in New Issue
Block a user