Created
January 13, 2009 00:43
-
-
Save alcides/46268 to your computer and use it in GitHub Desktop.
future syntax
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
# This is a study for a programming language I will create later this year. | |
# Suggestions gladly accepted | |
# Oh, and I'm also looking for a cool non-geek name :) | |
import os | |
animal is class(name) | |
#look, nothing here! | |
dog is class | |
say is f # f is a token. short for function. | |
print "bark" | |
for | |
food is "bone" # is is a token, same as = | |
cat is class | |
say is f | |
print "miau" | |
food = "fish" | |
to_s is name # ruby-like casts? Yep, name is visible here. | |
zoo is list | |
zoo insert dog("bobby") # that's right object <space> method <space> parameters | |
zoo insert cat("serafim") | |
zoo each(animal) | |
print (animal name) + " likes " + (animal food) | |
animal say | |
# --------------------------- | |
one = 1 | |
one IS 1 | |
square = f(i) | |
i**2 | |
square = f(i) i**2 | |
square = i->i**2 # I need a better lambda to work single and multi liner | |
square = i into i**2 | |
square = i into | |
i ** 2 | |
five = list | |
insert 1 | |
insert 2 | |
insert 3 | |
insert 4 | |
insert 5 | |
five is list 1 upto 5 | |
five is ( list ( 1 upto (5) ) ) | |
five is list 1,2,3,4,5 | |
five is list | |
(1 upto 5) each(i) | |
insert i # closures! | |
fib = f(i) | |
if i in (1,2) | |
1 | |
else | |
self(i-1) + self(i-2) | |
fib is i into | |
if (i equals 1) or i equals 2 then 1 | |
else self(i-1) + self(i-1) | |
# -------------------- | |
result = (os run "ls") split "\n" | |
result each(line) | |
print line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment