Skip to content

Instantly share code, notes, and snippets.

@slembcke
Created February 6, 2010 21:22
Show Gist options
  • Save slembcke/296969 to your computer and use it in GitHub Desktop.
Save slembcke/296969 to your computer and use it in GitHub Desktop.
KillableInterface : abstract class {
dyingNoise : abstract func -> String {}
}
KillableReference : cover {
obj : Pointer
impl : KillableInterfaceClass
}
KillableDog : abstract class extends KillableInterface {
}
kill : func(ref : KillableReference) {
"You killed it! It made a %s!" format(ref impl dyingNoise(ref obj)) println()
}
Dog : class {
dyingNoise : func -> String {"yowl"}
}
//operator as func(dog : Dog) -> KillableReference {
// ref : KillableReference
// ref obj = obj
// ref impl = impl
//
// return ref
//}
main : func {
KillableDog dyingNoise = Dog dyingNoise
fido := Dog new()
ref : KillableReference
ref obj = fido
ref impl = KillableDog
kill(ref)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment