Reference

Unsupported Forms

Find the supported replacement when Topaz rejects a form it does not support.

If topaz check rejects a familiar spelling, find its Topaz replacement below. For features without a direct replacement, choose an alternative that fits the result you need.

Run the supported forms

Install Topaz through First Program, then save this as unsupported-forms.tpz.

TOPAZ
import std.io

let mut count = 0
let values: Array<int> = [1, 2]
let transform: (int) -> int = value => value + 1

match values {
    case [head, ..tail] => {
        count = transform(head) + tail.length
    }
    case [] => {
        count = 0
    }
}

io.writeLine("{count}")

Check and run it from the folder containing the file.

BASH
topaz check unsupported-forms.tpz
topaz run unsupported-forms.tpz

The check succeeds, and the program prints the following result.

Output
3

let mut allows count to change. The pattern binds head to 1 and tail to [2]. transform(head) returns 2, and adding the tail length gives 3. The type (int) -> int describes the function stored in transform.

Replace unsupported spellings

If you triedUse instead
mut let count = 0let mut count = 0
count++ or count--count = count + 1 or count = count - 1
[T] as a typeArray<T>
function(T) -> U as a type(T) -> U
args: ...T...args: T
[head, ...tail][head, ..tail]
An anonymous function (...) { ... }A lambda such as value => value + 1
Backticks or ${value}Double quotes and {value} interpolation
String indexing or .lengthtext.scalars() followed by Array operations

In unsupported-forms.tpz, replacing let mut with mut let makes the check fail. Restore the let mut count declaration, then check and run the file again.

For imports, name the members you need. Mark exported declarations with export where they are declared. Modules & Visibility shows the forms. use, string or template module paths, export lists, wildcard exports, re-exports, and export-site renaming are unsupported.

Choose an alternative for an unsupported feature

The features below are unavailable in the current language. These alternatives solve the stated tasks and may require changing the program's structure.

TaskUnsupported featureCurrent choice
Inspect textGrapheme-cluster APIs and direct string slicesUse scalars() when Unicode scalar boundaries fit the task
Build text or structured templatesHTML and custom template tagsUse strings or the built-in p, r, sh, sql tags for their stated purposes
Express generic requirementsHigher-rank constraints and general dynamic protocol dispatchUse the supported named-function bounds in Functions & Generics
Describe recursive dataRecursive type aliasesUse supported enum declarations from Records & Nominal Data
Share declarations between modulesPackage re-exportsImport members from the module that declares them
Expand elementsGeneral iterable spreadUse Array spread in its supported positions, or iterate explicitly
Run work concurrentlyasync and awaitUse concurrent when collecting named results with a timeout fits the task
Close resourcesAsynchronous cleanupUse synchronous defer or supported using forms
Handle an expected failureFault catching and panic, throw, catchReturn a Result for recoverable errors
Read an optional field in a pipelineOptional-property pipe shorthandWrite an explicit expression using ?.

Topaz has no class inheritance or runtime reflection to inspect program structure. It also has no row polymorphism, which lets a generic record type leave some fields unspecified. See Records & Nominal Data for the data model. Numeric types do not convert implicitly, so an int does not automatically become a float in an expression.

A runtime fault stops execution. Changing its syntax cannot make it a recoverable Result. Prevent the invalid operation or use an API that returns an ordinary error value. See Null, Option, Result & Faults.

Rust forms such as &self, &mut self, Vec<T>, and use crate:: are not Topaz syntax. Use module-level impl Name, built-in collection types, explicit imports, and Topaz record updates.

Find examples in Syntax at a Glance. For operator corrections, continue with Operators & Expressions.