README.md

Teko

Teko is a statically typed scripting language that aims to combine the safety and scalability of Java with the quick start and powerful data structures of Python. The plan is for Teko to be both interpreted and compiled, à la Python; its interpretation-oriented syntax gives it the ease of use of a scripting language like JS, Python, or Ruby, while its static typing will hopefully allow compiled code to run at speeds comparable to other compiled languages like Java.

Language features

General design philosophy

Like other scripting languages, a Teko file can consist of just one line of code - no need to wrap in a class or a main() method.

Teko is not whitespace sensitive, using braces and semicolons to delimit syntax.

Other than being a statically typed scripting language, other elements of its design philosophy were the avoidance of implicit type coercion and of label overloading.

Functions

Defining functions in Teko looks similar to any other variable assignment:

int add(int n1, int n2) = { return n1 + n2; };

However, there are a few spooky things about Teko functions. Their return type and parameter set are immutable, and the parameter set is actually a struct. The definition is mutable though, and can be assigned on a different line than declaration, like any other variable.

Structs are actually pretty powerful data types in Teko. They support default values, and by extension so do functions. Parameter defaults work essentially identically to Python, allowing for positional arguments followed by keyword arguments.

Classes and Objects

Yeah, I'd like to build classes, class hierarchies, and generics into Teko at some point.

Open Design Issues

Function parameters as named structs

In Teko, function parameter sets are structs.

int f1(int n);
f1.args; // (int n)

Structs are objects which can be named with a variable, like anything else. This raises the possibility of declaring a function's parameter set as being a previously defined struct.

struct a = (int n);
int f1(a) = { return n; };

This further raises an even stranger possibility!

struct a;
int f1(a);
a = (int n);
f1 = { return n; };

Even I admit that's probably a step too far. A struct passed in a function declaration would presumably be passed by value; in fact, allowing anything like this opens the door to mutating a function's parameter set, which is definitely outlawed. It was just too interesting an idea not to write down.

Complex number syntax

I'd really like for complex numbers to be a primitive type in Teko, but expressing them raises all manner of hairy issues for my lexical and syntactic structure. Here was my original prototype for complex numbers:

comp z = 3 + 2i;

Firstly, this looks an awful lot like 2i is a complex number, and 3 is being implicitly coerced into adding. Secondly, is i a quantity (entailing an implicit multiplication in 2i)? Is it a conversion shorthand, like 2$? Does it affect the validity of i as a label elsewhere?

On a related note, is 2. two tokens, an integer 2 followed by the existing conversion shorthand ., or is it a single token denoting a real? Either way results in the same type for this particular expression, but is there a situation in which it matters?