nonsensation

Table of Contents

Header 1

Header 2

Header 3

Header 4

Header 5
Header 6

The match Statement / Expression

The lex-syntax: {:.code-comparison-bad} MatchExpressionStatement: match Expression { VariableExpression -> ExpressionStatement }

Design goals

Syntax Design

Case-clauses
A :: 
B -> 
C => 
D ~> 
E ~  
F >> 
Default / Match any clause
A :: handleA()
B -> handleB()
C => handleC()
D ~> handleD()
E ~  handleE()
F >> handleF()

or the C-way:

case A: handleA()
Multiple Patterns & Ranges
match x {
                   MyEnum.A >> print( "" ) ,
                    1 to 10 >> print( "match ranges" ) ,
               1 to 10 by 2 >> print( "also works with strides" ) ,
    "a" to "z" , "A" to "Z" >> print( "multiple patterns separated by comma" ) ,
                          _ >> print( "default, match-any" ) ,
             value : MyType >> print( "match types" ),
                   MyEnum.B >> goto MyEnum.A , # goto to another pattern
   MyEnum.C @label "catdog" >> print( "goto with label" ) ,
                   MyEnum.D >> goto "catdog" ,
                       null >> {
                            print( "multiple" )
                            print( "statements" )
                        } ,
}