Hatch

a programming language

Overview Definitions Objects Functions Closures Modules

Hatch is a little language that's based on closures and lazy evaluation, and transcompiles into Javascript. It's really only a toy, and half-finished at that (no lists, loops, or even non-integer numbers). Even so, I had fun making it, and I hope you have fun playing with it! Go find it on GitHub.

<< This is a comment. >>
a : 1
a << Returns: 1 >>
b : {
    x : 1
    y : 2
    z : "something unexpected"
    }
b.x << Returns: 1 >>
c : { (p q)
    add( mul(p p) mul(q q) )
    }
c(4 5) << Returns: 41 >>
d : {
    u : 40
    addToMe : { (v)
        add( u v )
        }
    }

d.addToMe(2) << Returns 42 >>
e : {
    public : "now you see me"
    _private : "now you don't"
    getPrivate : { (password)
        if(eq(password "gingko")
            _private
            "nuh-uh-uh! you did't say the magic word")
        }
    }
e.public, << Returns: now you see me" >>
e.getPrivate("hi"), << Returns: nuh-uh-uh! you did't say the magic word" >>
e.getPrivate("gingko") << Returns: now you see don't" >>