Something went wrong. Try again.
The Mesa programming language
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197msg := "Hello, world!"#> Hello, world!$print(msg)
total := 0
def count nums := [1, 2, 3] each num in nums do total := total + num endend
count
#> 6$print(total)
type Task(priority) def bump priority := priority + 1 end
def shadow each priority in [10, 20] do priority := priority + 1 $print(priority) end endend
task := Task(5)task.bump#> 6$print(task.priority)
other := Task(100)#> 11#> 21other.shadow#> 100$print(other.priority)
w := 1outside := 5
def h "module proc"end
type Rect(w, h) def read w end
def write w := 100 h end
def peek outside endend
rect := Rect(7, "field h")#> 7$print(rect.read)#> field h$print(rect.write)#> 100$print(rect.w)#> 1$print(w)#> 5$print(rect.peek)
type Tag(label) def empty? self.label == nil endend
done! := true#> true$print(done!)
tag := Tag(nil)#> true$print(tag.empty?)
a := 4#> true$print(a != 2)#> true$print(a!=2)
c! := 4#> true$print(c! == 4)#> true$print(c!==4)
#> type Str$print(Str)#> type Num$print(Num)#> type List$print(List)#> type Char$print(Char)#> 0$print(Str().size)#> []$print(List())
Str := "shadowed"#> shadowed$print(Str)
#---
#! runtime error: name 'unknown' is not defined
$print(unknown)
#---
#! runtime error: name 'inner' is not defined
def outer innerendouter
#---
#! runtime error: name 'unknown' is not defined
type Ctor(a, b: unknown)endCtor(1)
#---
#! runtime error: name 'leak' is not defined
each n in [1, 2] do when n == 1 then leak := true end when n == 2 then $print(leak) endend
#---
#! runtime error: name 'leak' is not defined
each k in {1: "a", 2: "b"} do when k == 1 then leak := true end when k == 2 then $print(leak) endend
#---
import Test.Other
Num := 5
#> 5$print(Num)#> type Num$print(Other.num)
def shadows Str := "local" Strend
#> local$print(shadows)#> type Str$print(Str)
#:other.msmodule Test.Other
def num Numend