Built-in Types

PIL only has object types, i.e. unlike Java there is no distinction between primitive types (e.g. int, float, char) and object types (e.g. String, Integer). All PIL built-in types are in the pil:: namespace, however, this namespace is imported automatically, so it can always be left out.

Object

    external class pil::Object {
      pil::Bool ==(pil::Object other);
      pil::Bool !=(pil::Object other);
      as<pil::String>;
      pil::reflect::Class getClass();
      pil::reflect::Class getClassInfo();
      Int hashCode();
    }

Bool

    external class pil::Bool {
      pil::Bool &&(pil::Bool other);
      pil::Bool ||(pil::Bool other);
    }

Int

    external class pil::Int {
      pil::Int +(pil::Int other);
      pil::Int -(pil::Int other);
      pil::Int *(pil::Int other);
      pil::Int /(pil::Int other);
      pil::Int %(pil::Int other);
      pil::Int ++();
      pil::Int --();
      pil::Bool <(pil::Int other);
      pil::Bool <=(pil::Int other);
      pil::Bool >(pil::Int other);
      pil::Bool >=(pil::Int other);
    }

Float

    external class pil::Float {
      pil::Float +(pil::Float other);
      pil::Float -(pil::Float other);
      pil::Float *(pil::Float other);
      pil::Float /(pil::Float other);
      pil::Float %(pil::Float other);
      pil::Bool <(pil::Float other);
      pil::Bool <=(pil::Float other);
      pil::Bool >(pil::Float other);
      pil::Bool >=(pil::Float other);
    }

Char

    external class pil::Char {
      pil::Bool <(pil::Char other);
      pil::Bool <=(pil::Char other);
      pil::Bool >(pil::Char other);
      pil::Bool >=(pil::Char other);
      pil::Char toUpperCase();
    }

Byte

    external class pil::Byte {
      pil::Bool <(pil::Byte other);
      pil::Bool <=(pil::Byte other);
      pil::Bool >(pil::Byte other);
      pil::Bool >=(pil::Byte other);
      pil::Byte <<(pil::Byte other);
      pil::Byte >>(pil::Byte other);
      pil::Byte &(pil::Byte other);
      pil::Byte |(pil::Byte other);
      pil::Byte +(pil::Byte other);
      pil::Byte -(pil::Byte other);
    }

String

    external class pil::String {
      pil::String +(pil::String other);
      pil::Char get(pil::Int index);
      pil::Int length;
      pil::Bool contains(String other);
      pil::Array<pil::String> split(String separator);
      as<pil::Int>;
      as<pil::Float>;
      as<pil::Bool>;
    }

MutableString

    external class pil::MutableString extends pil::String {
      new(pil::String initialString);
      new();
      void append(pil::Object str);
      void remove(Int index);
      // ...
    }

Collection

    @abstract
    external class pil::Collection<T> {
      pil::Bool contains(T o);
      pil::Int length;
      as<Array<T>>;
    }

Array

    @builtin
    external class pil::Array<T> extends pil::Collection<T> {
      new(Int size);
      new(T* values);
      T get(pil::Int index);
      T set(pil::Int index, T value);
      void sort();
    }

ExpandingCollection

    @abstract
    external class pil::ExpandingCollection<T> extends pil::Collection<T> {
      void add(T o);
      void remove(T o);
    }

List

    external class pil::List<T> extends pil::ExpandingCollection<T> {
      new();
      new(pil::Int initialSize);
      T get(pil::Int index);
      T set(pil::Int index, T value);
      void sort();
      void reverse();
      void insertAt(Int idx, T elem);
      void removeAt(Int idx);
      Int indexOf(T elem);
    }

Set

    external class pil::Set<T> extends pil::ExpandingCollection<T> {
      new();
      new(pil::Int initialSize);
    }

Map

    external class pil::Map<K,V> {
      new();
      void set(K key, V value);
      V get(K key);
      void remove(K key);
      pil::Bool contains(K key);
      pil::Set<K> keys; // read only
      pil::Map<K, V> clone();
    }

Exception

    external class pil::Exception {
      new();
      new(pil::String message);
    }

NullPointerException

    external class pil::NullPointerException extends pil::Exception {
    }

print(ln)

    external void pil::println(pil::Object o);
    external void pil::print(pil::Object o);