Back to Blog

Mist 0.4.0 is released, virtual methods, array types, and more

Klesti Selimaj
2 min read

New Features

Virtual Methods

The virtual keyword enables polymorphic dispatch through vtables. Methods marked virtual can be overridden in subclasses and will be dispatched dynamically at runtime:

pub class Animal
{
    pub virtual void speak(&self)
    {
        println!("...");
    }
}

class Dog : Animal
{
    void speak(&self) override
    {
        println!("Woof!");
    }
}

Array Types

Fixed-size array types are now supported with [T; N] syntax:

[i32; 10] numbers;    // Array of 10 i32s
[str&; 3] names;      // Array of 3 string references

Tuple Variable Declarations

Tuple variables can now be declared with explicit type annotations using as:

(i32, bool) as x, y = (1, true);

i32 a, b = (1, 2, 3);

Include Directives

C-style include directives for importing external files and crates:

#include <stdio.h>           // Global include
pub use my_crate::module;    // Use include
#include "local.mist"        // Local include

Syntax Changes

Allman Style Struct/Enum Fields

Struct and enum fields now use semicolons instead of commas:

// Before (v0.3.x)
struct Point { i32 x, i32 y }

// After (v0.4.0)
struct Point { i32 x; i32 y; }

Bug Fixes

  • Fixed default initializers in classes
  • Fixed the mapping system for error remapping
  • Fixed include manifest path resolution
  • Fixed various analyzer bugs
  • Fixed the publish command
  • Fixed completion pollution in LSP

Improvements

  • Updated bootstrap infrastructure
  • Migrated to core library for c_void and classes
  • Removed unnecessary lifetime annotations
  • Fixed generics and function type handling