3 [DRAFT] Future AerScript Versions Ideas
Rafal Kupiec edited this page 2019-12-21 12:32:20 +01:00

Ideas

This document describes an ideas for future versions of Aer language specification

  • Namespace support
  • Transient fields
  • Variadic methods
  • Pointers support

Exponentiation Operator

A right associative ** operator can be added to support exponentiation, along with a **= shorthand assignment operator.

printf("2 ** 3 = %d\n", 2 ** 3); // 8
printf("2 ** 3 ** 2 = %d\n", 2 ** 3 ** 2); // 512

Operator Overloading

It should be possible to redeclare or overload most of the built-in operators available in AerScript. Thus a programmer could use operators with user-defined object types as well. Overloaded operators are functions with special names the keyword operator followed by the symbol for the operator being defined. similar to any other function, an overloaded operator has a return type and a parameter list.

class Box {
    public float $breadth;
    public float $height;
    public float $length;

    object operator+(Box $box1, Box $box2) {
        object $box = new Box();
        $box->breadth = $box1->breadth + $box2->breadth;
        $box->height = $box1->height + $box2->height;
        $box->length = $box1->length + $box2->length;
        return $box;
    }
}

Methods Annotation

Implement Java-like annotations as a form of syntactic metadata that can be added to source code. They should be limited to methods. Some proposed annotations:

  • @Deprecated - Marks the method as obsolete. Causes a warning if the method is being called
  • @Unimplemented - Marks the method as not implemented. Causes a warning if the method is being called
  • @Executable - Mars the method as program entry point. Forces VM to launch this method instead of Program::main(). If such annotation is not specified, VM should fallback to Program::main() and throw error if none found