Last active
May 23, 2016 09:47
-
-
Save deathbeam/d42bb788f5d8f80e2548 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pythonic module system | |
from Sys import print | |
# Annotations and generic types | |
\:generic | |
class MyValue<T> | |
# Fat arrow closures means no implicit return | |
new = (value : T) => | |
@value = value | |
# Interfaces with default implementation | |
interface Greeter | |
# Thin arrow closures means return | |
greet = (name : MyValue<String>) : Void -> | |
print "Hello #name" | |
# Classes and OOP | |
class Person implements Greeter | |
new = (name) -> | |
@name = name | |
# Cool naming with support for - as delimiter | |
greet-self = -> | |
greet name | |
# Top-level expressions | |
name = MyValue<String>("Alice") | |
# Creating of objects | |
alice = Person(name) | |
# Dynamic methods, closures | |
alice.greet = (name) -> | |
print "#name is awesome" | |
# Calling of methods | |
# We will use ! operator, what is replacement for () | |
alice.greet-self! | |
# Above will output "Alice is awesome" to console | |
# vim: set ft=coffee: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment