Created
August 3, 2011 07:19
-
-
Save fsrc/1122089 to your computer and use it in GitHub Desktop.
Made up fantasy language FAL
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
# If I could design my own language, it would look something like this. | |
# | |
# + Indentation matters instead of curly braces. | |
# + Nothing but | |
# - Functions | |
# - Lists | |
# + Predefined types | |
# - Number = | |
# + = (Number) | |
# - = (Number) | |
# * = (Number) | |
# / = (Number) | |
# ... | |
# - String = | |
# append = (String) | |
# char = (index) | |
# - Date? = | |
# - Regex = | |
# test = (String) | |
# match = (String) | |
# + Built in currying | |
# + Interpreted, embeddable runtime. Much like Lua. | |
# - As such, the interpreter should be implemented in Ansi C, Java and any other platform to gain portability. | |
# + Some functions and objects is predefined | |
# - If = (Function, Function) | |
# - If = (Function, Function, Function) | |
# - While = (Function, Function) | |
# + Seamless distributed execution | |
# Functions | |
# | |
# Function that takes no arguments and returns a String object | |
fun = () "result of function" | |
# Is equal to | |
fun = "result of function" | |
# Is equal to | |
fun = | |
"result of function" | |
# Functions don’t need parenthesis when there are no arguments. | |
# Functions can be defined in one line. | |
# In essence, a variable assignment is infact a function returning a result. | |
fun = (var) "result of function" append var | |
# Is equal to | |
fun = (var) ("result of function" append var) | |
# Is equal to, where method 'append' is equal to method '+' | |
fun = (var) ("result of function" + var) | |
# Is equal to: | |
# (Notice that each level of nesting is indented by one space unit) | |
fun = (var) | |
"result of function" | |
append | |
var | |
# The interpretation is: | |
# Reference 'fun' is assigned a function that takes one argument. | |
# The function creates a String object that contains the text | |
# "result of function". The function then executes the append method | |
# of that object, passing the 'var' as argument. | |
# The function then returns the result. | |
# | |
# Nested objects is denoted with whitespace, not period. This results in a more mathematical syntax. | |
# | |
# To execute function bar in object foo, and let x be the result, the following syntax is used. | |
x = foo bar | |
# This is also equal to: | |
x = (foo bar) | |
# When nesting expressions, parantheses should be used around the expression. | |
x = 5 * (7 + 10) | |
# Which is equal to: | |
x = (5 * (7 + 10)) | |
# Note; the numbers 5, 7 and 10 is of type Number. The Number type contains method '+'. | |
# Condtitionals | |
If true, any_code, any_other_code | |
While true, any_code | |
# Currying | |
a = 5 + | |
# a is now a function that takes one arg (Number) | |
b = a 6 | |
# the range function is overloaded in three versions | |
range = (start, len, step) ... | |
range = (start, len) ... | |
range = (len) | |
a = range 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment