Skip to content
CryoCryo home
LanguageProject

27Roadmap

What comes after version 1.0, and what 1.0 knowingly leaves open. Version 1.0 freezes the language and the standard library's shape: a breaking change went in before the freeze, and what follows is additive, or an internal rewrite that changes no program's meaning. Nothing here has a date. The order within each list is not a schedule.

Known limitations in 1.0

Four defects are known and left open for 1.0. Each has a workaround, and each is a program that is refused or a program that compiles when it should not, never a miscompile of a program 1.0 accepts.

A string view can outlive the text it points into. A Str taken from an element of a temporary Array<String> and assigned to a variable that lives longer than the array compiles without a word, and reading it afterwards reads freed memory. Keeping a view only where it cannot outlive its owner is phase 3 of the memory-safety rollout, which 1.0 does not enforce. Until it is, bind the collection to a local that lives as long as the view, or copy the text into a String you own:

import std::collections::str::{ Str };
import std::collections::string::{ String };

function words(text: Str) -> Array<String> {
    mut result: Array<String> = Array::<String>::new();
    result.push(String::from_str(text));
    return result;
}

function main() -> int {
    const all: Array<String> = words(Str::new("kept"));   // lives as long as `kept` does
    mut kept: Str = Str::new("");
    for (word in all.iterate_references()) {
        kept = word.as_str();
    }
    return if (kept.length() == 4) { 0 } else { 1 };
}

T::from on a type parameter needs a bound. A path call on a type parameter finds methods only through the body's bounds, so T::from(value) in a body whose T has no bound is refused with E0358, even though implement<T> trait From<T> for T holds for every type. Write the bound:

import std::core::convert::{ From };

function through_from<T>(value: T) -> T where T: From<T> {
    return T::from(value);
}

function main() -> int {
    return if (through_from(7) == 7) { 0 } else { 1 };
}

A for loop in a generic body cannot loop over a parameter bounded only by Iterable. Such a body is refused where it is written (E0306), whether or not anything calls it. Bound the parameter by Iterator and pass it the collection's iterate(), or loop where the collection's type is known:

import std::core::iter::{ Iterator };

function count_all<I>(items: I) -> i64 where I: Iterator<i32> {
    mut n: i64 = 0;
    for (item in items) { n = n + 1; }
    return n;
}

function main() -> int {
    mut numbers: Array<i32> = Array::new();
    numbers.push(1);
    numbers.push(2);
    return if (count_all(numbers.iterate()) == 2) { 0 } else { 1 };
}

A Windows program links standard-library code it does not use. The empty program is about 1.7 MB on Windows, because an always-linked object holds a generic instance whose methods reach the hash map's keyed hasher and, through it, the secure random source. Nothing runs that the program does not call; it costs size only.

Memory safety

Version 1.0 enforces phase 1 of the memory-safety rollout: every local is initialised before it is read, no reference is carried out of its function, generic bodies are checked once against their own parameters, values are released once, and the run-time checks on indexing, division and shifts. The later phases are designed and not built. Each arrives in a 1.x release as a warning, so programs can move to it, and becomes an error at 2.0:

phaserules1.x warning2.0 error
2the operations that need unsafe, refused outside itW0019E0462
3views: a reference kept only where it cannot outlive its owner, and the collections handing out &T instead of T*W0020E0461
4loans: a place not moved, released or assigned while a reference to it is used, and shared-or-writable at every loanW0021, W0022E0450, E0451

Phases 5 (threads, with a thread-marker type) and 6 (the collections' change counters) come later still.

The language

  • Loops over references and generic collections. An iterator that yields &T, so a borrowing loop binds a reference instead of a pointer, and with it a loop over &[T] and the other references to an iterable; and a loop in a generic body over a parameter bounded by Iterable.
  • T::from on an unbounded type parameter. Member lookup on a type parameter answered by an implementation that holds for every type, so the bound above is no longer needed.
  • Tuples. Eq, Clone, Debug and Display for tuples structurally, as they have Copy, Send and Sync, and method calls on a tuple. Pair stays the convention for a public two-value result.
  • Text. A string literal whose type nothing declares becomes a Str, so "a,b".contains(",") finds Str's methods directly; and == with a string on the left of a Str.
  • Trait objects. Owning boxes, which take their drop, size and alignment from the table, and upcasting a subtrait object to one of its supertraits. Borrowed trait objects are in 1.0.
  • Associated constants of a trait used as values.
  • Paths through generic type aliases: type Stack<T> = Array<T>; Stack::<i32>::new().
  • Capturing closures in function-typed slots: a function value that carries its captures, so a capturing closure can be stored in a variable, field or element of function type.
  • Compound assignment through traits of its own, so += on a String appends in place.
  • A checked conversion from an integer to an enum, answering Option for a value no variant holds.
  • One literal form in a variant's payload. An integer or float written directly as a payload element, Some(-7) or Celsius(36.6), is its own kind of element today, tested apart from the literal pattern a tuple element or a nested pattern holds, Some((-1, 'q')). Both become the nested literal pattern, so one test and one type check serve every literal wherever it is written.
  • Compile-time execution, and with it a context allocator scope for the new expressions inside a block.

Packages and the toolchain

  • Two major versions of one library in a build: each package takes the major version it asks for, with versioned symbols and a rename key in cryoconfig. In 1.0 a build holds one version of each library.
  • A package registry, naming a library and a version requirement without a URL.
  • A lint tool built on the compiler as a library, as the language server is.
  • The compiler's pipeline: the checked tree lowered through a high-level and a mid-level representation before LLVM IR.

The standard library

Left to packages: regular expressions, compression, cryptography beyond SHA-1, SHA-256 and HMAC, big integers, memory-mapped files, the time zone database, Unicode normalization and collation, glob matching, and the less common collections. After 1.0 in the library itself: a reactor for pipes on Windows (asynchronous child I/O works through the blocking pool today), and a core tier free of the C library for the runtime.