Pyli/Types/Environment

From Jonathan Gardner's Tech Wiki
Jump to: navigation, search

Introduction

The Environment object is the gateway to all of the scoping issues in Pyli. It has the following methods and attributes.

Methods

  • (lookup env &name): Looks up a variable in the lexical environment. Only accepts Text or &(dynamic &name).
  • (set env &name value): Sets the variable name to value. Will look up through the parent environments. Error if the name isn't defined. Accepts expressions for the name, such as &(dynamic &name).
  • (define env &name value): Declares the variable name in the top lexical environment. OK to rewrite existing variables. Can only use Text for the name.
  • (extend env &var value &var value ...): Creates a new environment that extends this one, providing the new variables and values. var can be Text or &(dynamic &name)
  • (freeze env &var):
  • (thaw env &var):

Attributes

  • (el env &vars): The vars in this environment.
  • (el env &dynamic-vars): The dynamic vars.
  • (el env &parent): The parent environment. Same as (lookup env &*parent-env*)
  • (el env &calling): The calling environment. Same as (lookup env &(dynamic &*parent-env*))