Created
February 6, 2010 21:22
-
-
Save slembcke/296969 to your computer and use it in GitHub Desktop.
This file contains 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
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