Skip to content

TL2 Features

Meir Cohen edited this page Mar 14, 2018 · 1 revision

First compiler with state

  1. Blocks now not need to end in blank line
  2. Expressions can have multiple function calls
  3. Classes can now have methods, declared by func inst inside the class, self can be used inside
  4. All system functions changed to methods
  5. Correct handling of return values, out is removed
  6. Array indexing works anywhere with [index], [] <type> is removed
  7. String indexing str[index]
  8. Array and String slicing anywhere
  9. Expression initialization
  10. Complex else-if expressions
  11. Error traceback now prints MR file information
  12. Inheritance: class3es can inherit from one base class
  13. Basic polymorphism: class can define func dynamic methods that will be overridden by inherited classes. But:
    • a class without dynamic methods should be declared using static instead of class
    • All func dynamic methods should have an implementation
    • All inheriting classes must implement all dynamic methods of it's bases - and in the same order
    • New dynamic methods must be added after the base class dynamic methods
  14. References are automatically up-caste in simple assignment and function arguments
  15. Methods can be called directly by [class-name].[meth-name]([self], ...)
  16. return is added to functions end automatically - no need to add it manually
  17. Basic multiple file support: allow splitting of one file to multiple files - MR2 compiler can receive multiple files and treat them as one file in the given order. Generates C file for each file where the last one includes all others.
  18. Support empty references, set with _ and test with ? [reference]

Clone this wiki locally