NativeEnvironment constructor

NativeEnvironment([
  1. Environment? owner
])

Implementation

NativeEnvironment([Environment? owner]) : super(owner) {
  // basic functions
  define(Name('define'), _define);
  define(Name('lambda'), _lambda);
  define(Name('quote'), _quote);
  define(Name('eval'), _eval);
  define(Name('apply'), _apply);
  define(Name('let'), _let);
  define(Name('set!'), _set);
  define(Name('print'), _print);

  // control structures
  define(Name('if'), _if);
  define(Name('while'), _while);
  define(Name('and'), _and);
  define(Name('or'), _or);
  define(Name('not'), _not);

  // arithmetic operators
  define(Name('+'), _plus);
  define(Name('-'), _minus);
  define(Name('*'), _multiply);
  define(Name('/'), _divide);
  define(Name('%'), _modulo);

  // arithmetic comparators
  define(Name('<'), _smaller);
  define(Name('<='), _smallerOrEqual);
  define(Name('='), _equal);
  define(Name('!='), _notEqual);
  define(Name('>'), _larger);
  define(Name('>='), _largerOrEqual);

  // list operators
  define(Name('cons'), _cons);
  define(Name('car'), _car);
  define(Name('car!'), _carSet);
  define(Name('cdr'), _cdr);
  define(Name('cdr!'), _cdrSet);
}