Created
July 28, 2011 21:52
-
-
Save nijikokun/1112672 to your computer and use it in GitHub Desktop.
Fake language, based on python, ruby, perl, and java.
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
# Mockup language by Nijikokun <nijikokun@shortmail.com> (http://twitter.com/nijikokun) | |
# | |
# Based on Ruby, Perl, Java, Python | |
# Minimal Special Chars, Literal strings. | |
# | |
# @copyright 2011 | |
# Core imports should be located in "system" | |
import system | |
import system.time | |
import system.log | |
interface Animal: | |
# Type of Animal | |
String type | |
# Name of Animal | |
String name | |
# Methods | |
new walk() | |
new eat(String food) | |
new sleep(Time time) | |
class Dog imp Animal: | |
String type eq self.__class__.name | |
String name | |
new Dog(String name): | |
if name.empty | |
self.name eq "spots" | |
else | |
self.name eq name | |
new walk(): | |
log.info -> "Taking %s the %s for a walk." % self.name, self.type | |
new eat(String food): | |
if food.empty | |
log.warning -> "You are a bad pet owner!" | |
end | |
log.info -> "Giving %s some %s to eat." % self.name, food | |
new sleep(Time time): | |
if time.lookAhead -> "5m" lt system.time.relative -> "m" | |
log.severe -> "The %s needs more sleep than %t" % self.type, time.relative -> "m" | |
end | |
log.info -> "%s the %s slept for %t" % self.name, self.type, time.amount(time.relative -> "h") | |
# Create a dog ~ | |
# | |
# Variations: | |
# init Dog dog("Awsm") - this would work as well. | |
# Dog dog("Awsm") - would work | |
# Dog as dog -> "awsm" | |
# | |
# (init is not necessarily needed, it would be default keyword for blank statement unless specifically in blocks or otherwise.) | |
init Dog as dog -> "Awsm" | |
# Since we aren't in a block, spacing shouldn't matter. | |
dog.walk | |
# Quick style with specific variable instancing. | |
dog.eat -> food => "Bacon Treats" | |
# Alternate method style | |
dog.sleep(time.init -> "1h") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment