name = "Kamby Language"
def hello {
print "Hello, " who "!"
print("You are " age " years old.")
}
hello(who : name, age : 3 + 1)
name = "Kamby Language"
def hello {
print "Hello, " who "!"
print("You are " age " years old.")
}
hello(who : name, age : 3 + 1)
Variables can contain any type of data, including number, strings, lists or even blocks of code.
message := 'Hello, World!' # Define a new variable
message = 'Bye, bye' # Edit variable value
def message 'Hello again!' # Append new 'message' in stack ("def" == ":=")
del message # Remove last 'message' in stack
message # Message has old value 'Bye, bye'
Variables are not unique. You can declare multiple values for the same variable name using ":=" and append in the stack. If you want to edit the last declaration, just user simple "=" operator. To remove the last variable with specific name in stack, use "del varname"
You can return the value of some stack item using index instead of var name
num1 = 12 // Change num1 value or define if it doesn't exist
num2 = 23
$0 // Return last item value from stack. 23
$1 // Return the second item from stack. 12
Atoms like numbers and strings can be named and not saved in the stack. This is useful to name a value in a list item.
list = [fistName : 'John', lastName : 'Doe', age : 25]
print(list . firstName) // John
print(list . age) // 25
print(list . 1) // Doe
Basically those three types of lists has the same structure but act different when executed.
// Expressions will be evaluated an return the value
expression = (1 + 2)
// Binary operators wraps itself in a expression
expression = 1 + 2
/*
List items are separated by spaces, comma or semicolon.
Expressions return will be attribuited to item
*/
list = ['first item' (1 + 2)]
// Blocks are lists of expressions that can be called after declaration
block = {
print(message)
}
For source code or blocks, each line is considered an expression. To execute a block, just call it as first item of an expression. The arguments are be appended to the internal block variables stack.
sum = { $0 + $1 }
sum 2 3
/* or */
def sum { first + second }
sum(first : 2, second : 3)
Lists can be sent as a context appended to global variables context.
name := 'Global name' // Declare a new variable in current stack
person = [
name : 'Local name'
age : 20
]
name // Return 'Global name'
person . name // "person" is set as context
// "name" returns list's "name" item
+ - * /
&& || == != >= <= > <
Operator "+" will sum two numbers, or concatenate two strings.
1 + 2 // 3
"Kamby" + "Lang" // KambyLang
MIT