RevengerWizard/teascript

[Feature Suggestion] Typed variables

Clozent opened this issue · 1 comments

It would be neat if there was an option to specify a variable's type(s), kind of like in Typescript.

Hi, thank you for the feature suggestion! Having typed variables like in Typescript could be interesting I had this kind of idea rolling around:

var a : string = 'hello'
const b : list = [1, 2, 3]

function f(a : number, b : number) : number
{
    return a + b
}

I think in the world of dynamically typed interpreted languages there are primarily two possible inspirations that could be considered:

  • Python
  • Typescript

In Python type annotations are usually ignored entirely by the parser and the interpreter itself. They're instead used as comments or used together with external linters to provide a minimal type safety to the language in some situations. Actually, Python has also some type oriented functions, such as the types module with the various cast, not really convinced with that since it would be hard to avoid runtime penalties for Teascript.

Typescript is also nice, more strongly typed than Python's types annotations, which are inspired by Typescript; the snippet is pretty much Typescript code.

For Teascript I'm leaning towards Python's type annotations, that is, ignored by the parser.
As of now, I'm mostly refactoring the source code, changing and adding stuff to the language. Types would require external editor tools to be useful, probably written in Teascript? Not sure.

I think for now we can keep the issue opened as a future reference.