Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Speedy.js Language Reference

Micha Reiser edited this page Jun 13, 2017 · 3 revisions

Speedy.js is a subset of TypeScript, and therefore, only valid TypeScript files (consolidate the TypeScript Language Specification) are valid in Speedy.js. This page describes the TypeScript features supported by Speedy.js. Features not listed on this page are unsupported.

Declarations

Speedy.js only supports let and const declarations. var declarations are not supported.

Types

Primitive Types

The following primitive types are supported:

  • number
  • int
  • boolean

Object Types

The only objects supported are Classes and Arrays. Object literals are (not yet) supported.

Classes

Classes are supported including constructors and fields. Class inheritance is not (yet) supported.

Array Types

The language supports arrays containing elements of a single type (base or object type). Arrays support the following methods, properties, and accessors.

  • [x1, x2, x3]: Array Literals
  • new Array<T>()
  • new Array<T>(int)
  • new Array<T>(x1, x2, x3)
  • [index: int] Only integer indexes are supported. The semantics differ from JavaScript in that the default value is returned if the array index is out of bound instead of returning undefined.
  • [index: int] = value: Only integer indexes are supported. The semantics differs from JavaScript as it throws if the index is out of bound instead of automatic resizing the array.
  • .length
  • .fill
  • .push
  • .unshift
  • .pop: The semantics differ from JavaScript in that the default value for the array element type is returned instead of undefined if the array is empty.
  • .shift: The semantics differ from JavaScript in that the default value for the array element type is returned instead of undefined if the array is empty.
  • .slice
  • .splice

Any

Is not and never will be supported.

Expressions

this Keyword

The this keyword is supported inside class methods.

Identifiers

πŸ‘

Literals

  • true, false
  • number literals (0.0, 2.3, 9.3)
  • int literals (0, 2, 9)
  • Array literals
  • undefined

Parentheses

πŸ‘

Property Access

Only accessing existing properties is allowed.

  • Dot Notation: Supported if the property exists
  • Bracket Expression: Unsupported

The new Operator

Only if the expression is a class.

Function Calls

Supported except if the expression is not a class (needs to be called with new).

Unary Operators

  • !
  • -
  • --
  • ++
  • +
  • ~

The delete, void and typeof operator are not yet supported.

Binary Operators

  • &, &=
  • &&
  • *, *=
  • **, **=
  • |, |=
  • ||
  • ^, ^=
  • ===, !==
  • >, =>
  • >>, >>=
  • >>>, >>>=
  • <, <=
  • <<, <<=
  • -, -=
  • %
  • +, +=
  • /, /=
  • =

The comparison operators for number differ from the JavaScript specification as values are compared unordered. Therefore, the result of a comparison of NaN to any other value is undefined.

Unsupported are:

  • == Loos equality
  • in
  • instanceof

Conditional Operator

πŸ‘

Assignment Operators

πŸ‘

As Operator

πŸ‘

Statements

Block

πŸ‘

Variable Statements

Simple let and const variable declarations are supported (without destructuring)

If Statement

πŸ‘

While Statement

πŸ‘

Break Statement

πŸ‘

Continue Statement

πŸ‘

For-In Statement

Only for Arrays

Return Statement

πŸ‘

Functions

Functions need to be declared at the root level of the file. Only Function Expressions or Arrow Functions are not yet supported.

  • Optional arguments
  • Default values
  • Vararg arguments

Not supported are:

  • Closures
  • Function Overloads
  • Generic Functions
  • Vararg arguments for entry functions

Environment

The following objects and operations from the runtime environment are supported.

Math

  • cos
  • log
  • pow
  • sin
  • sqrt

isNaN

πŸ‘