Esca is an experimental strongly-typed language which compiles to Go.
The main goal is type-safe programming which makes the best of features of Go.
- Type Safety: Strongly typing, type inference.
- Interoperable: Using goroutine, calling libraries in Go.
- Friendly Syntax: Syntax like Go, simplifies idioms of Go.
- Enumeration: Defining common types for grouping related values.
- Pattern Matching: Comparing and destructing values easily.
- Bitstring: Constructing binaries and matching binary patterns.
- Generics: Avoiding duplication of definitions.
- Tail Recursion Optimization: Supporting efficiency tail recursion functions.
- OCaml 4.04.2+
- OPAM 1.2.2+
- OMake 0.9.8.6-0.rc1
- Core 0.9.1+
- Menhir 20170607
$ opam pin add omake 0.9.8.6-0.rc1
$ opam pin add esca .
Apache License, Version 2
func main() {
...
}
IMPLEMENTING
// comment
f(x, y, z)
func add(x: Int, y: Int) {
return x + y
}
tailrec func findFixPoint(x: Double) -> Double {
if x == math.cos(x) {
return x
} else {
return findFixPoint(math.cos(x))
}
}
// no arguments
{ print("hello") }
// no return
{ x, y in show(x + y) }
// return
{ x, y in return x + y }
if x = y {
print("x = y")
} else {
print("x != y")
}
NOT YET IMPLEMENTED
guard is_ok else {
print("not ok")
}
guard name := get_name() else {
print("no name")
}
print(name)
for i in 0...10 {
show(i)
}
func fizzbuzz(i: Int) {
switch (i % 3, i % 5) {
case (0, 0):
print("FizzBuzz")
case (0, _):
print("Fizz")
case (_, 0):
print("Buzz")
default:
show(i)
}
}
return
return value
pass file := os.Open("foo.txt") else { error in
log.Fatal(error)
}
In Go:
file, err := os.Open("foo.txt")
if err != nil {
log.Fatal(error)
}
()
true
false
"Hello, world!"
&i
[] // empty
[1, 2, 3]
(1, 2, 3)
[:] // empty
["a": 1, "b": 2, "c": 3]
1...10 // 1-10
1..<10 // 1-9