mfichman / jogo

High(er) performance compiled programming language with clean, powerful syntax
MIT License
6 stars 1 forks source link

Implement type matching in 'match' statements #51

Open mfichman opened 11 years ago

mfichman commented 11 years ago
any Any = "string"
match any {
    with v String:
    with v Int:
    with v Float:
    with *:
}

With guards:

any Any = "string"
match any {
    with v String if v =~ "foo":
    with v String:
    with v Int:
    with *:
}

With destructuring:

any Any = Circle(10.)
match any {
   with v String:
   with Circle(radius) if radius == 10:
   with Rectangle(width, height):
   with *: 
}