Slang - Programming Language

Introduction

Hello World

Comments

Doc Comments

Values

Control Flow

The match Expression

Functions

FunctionType   = "func" Identifier "=" Signature
Signature      = Parameters [ Result ]
Result         = "->" Parameters | Type
Parameters     = "(" [ ParameterList [ "," ] ] ")"
ParameterList  = ParameterDecl { "," ParameterDecl }
ParameterDecl  = [ IdentifierList ]

Keywords

All keywords:

break continue for if else while loop when then ret func type meta requires constraint ensures assert assume implements inherits interface abstract pure throw except try catch defer default var val ref ptr arr out in const let mut mutable readonly immutable external internal extern mod module package include import export pub public private protected delete new test switch match null undefined defined nil nul nan inf and or true false not is as cast goto do this self super base mixin ctor dtor debug object global local inline namespace use using await yield async static final sealed virtual operator rethrow map

dynamic void byte bool boolean integer numeric decimal

match

As expression:

var x = match expr {
    pattern -> result-expr
}

All result-expr must be expressions. Can also be a statement-expression:

var x = match expr {
    null -> {
        if something
            ret A
        ret B
    }
}

As statement:

match expr {
    pattern -> statement
}

Types & Typedeclarations

struct

type struct : meta = {

}

type MyStruct : struct = {
    val Value : integer = 42
}