F RANZ I NC. Making Environments Accessible in Common Lisp By Duane Rettig June, 2005.

Slides:



Advertisements
Similar presentations
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Advertisements

Variables, Environments and Closures. Overview We will Touch on the notions of variable extent and scope Introduce the notions of lexical scope and.
1 Compiler Construction Intermediate Code Generation.
CSE341: Programming Languages Lecture 16 Datatype-Style Programming With Lists or Structs Dan Grossman Winter 2013.
Recursion vs. Iteration The original Lisp language was truly a functional language: –Everything was expressed as functions –No local variables –No iteration.
ISBN Chapter 10 Implementing Subprograms.
1 Scheme Scheme is a functional language. Scheme is based on lambda calculus. lambda abstraction = function definition In Scheme, a function is defined.
Tutorial 6 & 7 Symbol Table
Functional programming: LISP Originally developed for symbolic computing Main motivation: include recursion (see McCarthy biographical excerpt on web site).
Functional programming: LISP Originally developed for symbolic computing First interactive, interpreted language Dynamic typing: values have types, variables.
Compilation 2007 Scopes and Environments Michael I. Schwartzbach BRICS, University of Aarhus.
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
CASE Tools And Their Effect On Software Quality Peter Geddis – pxg07u.
Allegro CL Certification Program Lisp Programming Series Level I Session Overview of Common Lisp.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Functional Programming Universitatea Politehnica Bucuresti Adina Magda Florea
F RANZ I NC. Optimizing and Debugging Programs in Allegro CL By Duane Rettig April, 2007.
RELATIONAL FAULT TOLERANT INTERFACE TO HETEROGENEOUS DISTRIBUTED DATABASES Prof. Osama Abulnaja Afraa Khalifah
Functional Programming and Lisp. Overview In a functional programming language, functions are first class objects. In a functional programming language,
Binding UI Components to Data. Adding UI Components to the Page You can create components on a page by: Dragging a component from the Component Palette.
COMPILERS Symbol Tables hussein suleman uct csc3003s 2007.
Programming Languages by Ravi Sethi Chapter 6: Groupings of Data and Operations.
Allegro CL Certification Program Lisp Programming Series Level I Session Basic Lisp Development in the IDE.
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Prolog Program Style (ch. 8) Many style issues are applicable to any program in any language. Many style issues are applicable to any program in any language.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
CS536 Semantic Analysis Introduction with Emphasis on Name Analysis 1.
CSE (c) S. Tanimoto, 2002 AI Techniques 1 Where and When Do Symbols Refer to Values and Functions? Scope and Extent of Bindings Bindings Scope Extent.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Compiling “premature optimization is the root of all evil.” -Donald Knuth.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
REST By: Vishwanath Vineet.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
Macros and general code walkers in Lisp: how useful! or, how useful? Ernst van Waning
Chapter – 8 Software Tools.
CS412/413 Introduction to Compilers Radu Rugina Lecture 11: Symbol Tables 13 Feb 02.
Familiarizing with UNIX Commands. UNIX Commands Unix systems are heavily command based. This often makes us feel uncomfortable. Moreover the system is.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Advanced Programming in C
Lecture 3 Translation.
Advance OOP in PHP.
CS 326 Programming Languages, Concepts and Implementation
Variables, Environments and Closures
The role of abstractions
Fundamental of Java Programming
Business Process Measures
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
UML Class Diagrams: Basic Concepts
Names, Scopes, and Bindings: Scopes
Variables, Environments and Closures
Scope, Visibility, and Lifetime
Functions and Macros.
More Object-Oriented Programming
Procedures App B: SLLGEN 1.
CSE S. Tanimoto Explicit Function Application
Lisp: Using Functions as Data
6.001 SICP Variations on a Scheme
Defining Macros in Lisp
Clojure Macros.
Peter Seibel Practical Common Lisp Peter Seibel
Lisp: Using Functions as Data
Bindings, Scope, and Extent
Bindings, Scope, and Extent
Common Lisp II.
Recursive Procedures and Scopes
Product Training Program
LISP primitives on sequences
Abstract Types Defined as Classes of Variables
Presentation transcript:

F RANZ I NC. Making Environments Accessible in Common Lisp By Duane Rettig June, 2005

F RANZ I NC. What is An Environment? A set of bindings of names to values A context within which to work Parameterizations of behaviors

F RANZ I NC. Need for Lexical Environments (defun foo (x y z) (flet ((bar (x) (1+ x)) (bas (y) (+ x y))) (+ x (bar y) (baz z))))

F RANZ I NC. Need for Lexical Environments (let ((x (foo)))... (let ((x (bar)))... )... )

F RANZ I NC. Need for Dynamic Environments ;; In lisp: (defmacro foo (x) `(car,x)) ;; In a file: (defmacro foo (y) `(1+,y)) (defun bar (x) (isqrt (foo x)))

F RANZ I NC. Typical Implementation of Environments (let ((x 10))... (symbol-macrolet ((x 'foo))... (let ((x 20))... ;; here: ))) %venv% <= (... (x. 20)... (x #.*sm-marker*. foo)... (x. 10)...)

F RANZ I NC. Problems with list-style Environments Environment has no identity –Multiple lists are necessary –Objects not distinguishable as environments Accesses can be long for deep contour nesting Persistence and contour structure not automatic

F RANZ I NC. Desired Representation of Lexical Environment Elements Hash: x Contours: (lexical 20) (lexical 10) (symbol-macro foo) Old: New: xxx Search direction Search direction

F RANZ I NC. Environments Access Design Goals (part 1) Compatible with Common Lisp Spec where possible Open Source Start with CLtL2 definition, moving away only when necessary Move the Language forward –Allow the compiler to be more transparent –Allow portability of optimizations

F RANZ I NC. Environments Access Design Goals (part 2) Fast (building, access) Portable (on several levels) Controllable Persistence describes the contour forms easy to conceptualize the program structure allow multiple entry and annotation for multiple compiler passes and for debuggers Consistent for compilation and interpretation

F RANZ I NC. Major Departures from Environments in CLtL2 Entries are bindings, not just names Environments have “kinds” Dynamic environment component is added Augment-environment can reuse object Declarations are done differently –Define-declaration has different syntax –Declarations sometimes added after variable bindings

F RANZ I NC. Pictorial View of Environment Objects lexical namespaces base Dynamic namespaces e1 e5 e7 e4 e3 e2 e6 e8 nil

F RANZ I NC. Environment Kinds Interpreter (for lisps with interpreter) Compilation (compilation-walking in 7.0) Evaluation Compiler (compilation in 7.0) Macros-only

F RANZ I NC. Variables Associated with Environments *interpreter-environment* *compilation-unit-environment* [*compile-file-environment* in Allegro CL 7.0] *evaluation-environment*

F RANZ I NC. *interpreter-environment* Usage Only available when an interpreter exists Hard to capture - REPL continuously binds

F RANZ I NC. *compilation-unit-environment* Usage Created when new compile-file or with- compilation-unit established Can be built with either –sys:make-compilation-unit-environment or –sys:make-compile-file-environment (deprecated)

F RANZ I NC. *evaluation-environment* Usage Read-only feel - definitions taken from environment but stored globally

F RANZ I NC. Extensions Beyond the Spec Compiler environments Extra arg to macroexpand/macroexpand-1 for special operators Environments extend to compilation-unit

F RANZ I NC. To Do: “Split” define-declaration to allow redefinitions and development Add expression-information and :expression argument to augment-environment Encourage CL vendors to make use of this module Accept suggestions

F RANZ I NC. Levels of Portability/Porting Level 0: Level 1: Level 2: Level 3: Level 4:

F RANZ I NC. Levels of Portability/Porting Level 0: –Implementation has its own proprietary (open or not) representation Level 1: Level 2: Level 3: Level 4:

F RANZ I NC. Levels of Portability/Porting Level 0: Proprietary Level 1: –Compilation and operation of the basic functionality Level 2: Level 3: Level 4:

F RANZ I NC. Levels of Portability/Porting Level 0: Proprietary Level 1: Basic Level 2: –Current environment emulated at the Environments Access interface level Level 3: Level 4:

F RANZ I NC. Levels of Portability/Porting Level 0: Proprietary Level 1: Basic Level 2: Emulation Level 3: –Environments Access holds the information, Proprietary interface queries it Level 4:

F RANZ I NC. Levels of Portability/Porting Level 0: Proprietary Level 1: Basic Level 2: Emulation Level 3: Transitional Level 4: –Environments Access fully integrated into compiler, optionally interpreter proprietary representation unused or deprecated

F RANZ I NC. Levels of Portability/Porting Level 0: Proprietary Level 1: Basic Level 2: Emulation Level 3: Transitional Level 4: Full

F RANZ I NC. Current Levels of Support

F RANZ I NC. Current Links environments.htm ( envaccess-des)

F RANZ I NC. Look at the Implementation (switch to Linux) Bring up lisps and demonstrate Environment building/access Look at source code for major functions

F RANZ I NC. Thank You.