JScheme : A Scheme Interpreter Embedded Within Java Source Code

Size: px
Start display at page:

Download "JScheme : A Scheme Interpreter Embedded Within Java Source Code"

Transcription

1 JScheme : A Scheme Interpreter Embedded Within Java Source Code CPSC 511 Term Project by Jeff Sember Abstract Mixing two or more programming languages together within a single project can be nontrivial, involving different types of source code that must be compiled by different programs to generate various object or class files. We demonstrate a novel method of implementing JScheme, a variant of the Scheme language, that embeds both its source and object code within standard Java source files. We provide a compiler that scans Java source files, detecting JScheme source within Java comments, and compiles this source so that the resulting procedures and definitions are accessible to the Java code. Java and JScheme code can thus be used together in a development process that requires only the provided JScheme compiler and runtime class library. We investigate advantages and drawbacks of this approach, and discuss future enhancements. 1 Introduction Mixing two or more programming languages together within a single project is usually non-trivial. Code written in different languages are usually are kept in separate files, which must be compiled and/or interpreted by different programs. Some languages, such as C++, involve both source and header files that must be kept synchronized, which further complicates the development process. For all but very small programs, determining what files need to be recompiled can be a challenge, relying on dependencies between the source elements. As a result, the build process is usually coordinated by an external makefile or by an integrated development environment (IDE). The Java programming language improves this situation in two ways. First, there are no header files per se; a class file is self-contained within a single source file (though dependencies may still exist due to interfaces and inherited classes). Second, the Java compiler automatically recompiles only those classes that require recompilation, which negates the need for a makefile (though they are often used for other elements of a Java programming project). 1

2 Combining Java code with code written in another language is still not a trivial process. Compiling the other language s source may require the use of a makefile or IDE, and interaction between the different languages at runtime requires a special library, such as the Java Native Interface [5]. We take a different approach to allow a program to use both Java and JScheme code. JScheme code is contained within standard Java source files, by being embedded within Java multiline comments. Support for JScheme is achieved in two stages: first, the Java source files are compiled by the JScheme compiler, which parses the embedded JScheme code and writes the results back into the same Java source file in a compact form. Second, during the normal execution of the Java application, the JScheme code is evaluated by a provided runtime package to support interaction with Java code. We would like to stress that we do not change the syntax of Java source files; they remain standard Java, and must be compiled by a Java compiler, as the JScheme compiler only processes the JScheme source code. In section 2, we describe the JScheme language. In section 3, we describe how the JScheme compiler is used to compile JScheme source code, and how a Java program can interact with the compiled code. Section 4 delves into some details of how JScheme has been implemented. We finish with some results and concluding remarks in section 5. 2 The JScheme language JScheme implements a subset of the Scheme [1] language. For simplicity, we have omitted certain features of the Scheme language; for instance, the only numeric type supported is signed integers, and no support for continuations is provided. We have also not optimized procedure evaluations to perform tail-recursion efficiently. The JScheme grammar is shown in figure 1. JScheme contains a number of predefined procedures; see figure 2. For documentation describing these procedures, see [1]. The one nonstandard procedure included in this list is currbindings, which returns a string describing the current environment bindings. 3 Working with JScheme This section describes how JScheme source code is embedded within Java source files, and how the code can be used by a Java program. 3.1 Storing JScheme source code within Java source files A JScheme <program> element is wrapped in a Java multiline comment in the following way: /*s <program> */ 2

3 <program> ::= <elem>* <elem> ::= <exp> <def> <import> ( begin <elem>+ ) <import> ::= #import <file:string> <def> ::= ( define <id> <exp> ) ( define ( <id> <formal:id>* ) <body> ) ( define ( <id>. <varformals:id> ) <body> ) ( define-datatype <name:id> <predicate:id> <dt-var>* ) <body> ::= <def>* <exp>+ <dt-var> ::= ( <variant:id> <dt-field>* ) <dt-field> ::= ( <field:id> <predicate:expr> ) <lit> ::= <boolean> <number> <character> <string> <quotation> <boolean> ::= #t #f <character> ::= #\<any character> #\space #\newline <quotation> ::= <datum> (quote <datum>) <datum> ::= <boolean> <number> <character> <string> <symbol> <list> <vector> <symbol> ::= <id> <keyword> <list> ::= ( <datum>* ) ( <datum>+. <datum> ) <datum> <vector> ::= #( <datum>* ) <exp> ::= <id> <lit> <proccall> <lambdaexp> ( if <test:exp> <consequent:exp> [<alternate:exp>] ) ( set! <id> <exp> ) ( cond <cond_clause>+) ( cond <cond_clause>* (else <exp>+)) ( and <exp>*) ( or <exp>*) ( let [<id>] ( <binding>* ) <body> ) ( let* ( <binding>* ) <body> ) ( letrec ( <binding>* ) <body> ) ( begin <exp>+ ) ( cases <name:id> <expr> <case>* [(else <def:expr>)] ) ( do ( <do_var>* ) ( <test:exp> <after:exp>* ) <cmd:exp>* ) <case> ::= (<variant-name:id> ( <field:id>* ) <body> ) <proccall> ::= ( <operator:exp> <operand:exp>* ) <lambdaexp> ::= ( lambda <formals> <body> ) <formals> ::= ( <id>* ) <id> <cond_clause> ::= ( <condition:exp> <exp>+ ) (<exp>) <binding> ::= (<id> <exp>) Figure 1: JScheme grammar 3

4 * + - / < <= = > >= add1 append boolean? cadr car cdr char->integer char? cons currbindings display equal? eqv? expt foldl foldr integer->char length list list->vector list-of list-ref list? make-vector map member newline not null? number->string number? pair? printf procedure? reverse set-car! set-cdr! string->symbol string-append string-length string-ref string? sub1 symbol->string symbol? vector vector->list vector-fill! vector-length vector-ref vector-set! vector? write-char Figure 2: JScheme library procedures 4

5 The s prefix tells the JScheme compiler that this Java comment contains a JScheme <program> element. Each of these comments must be within a Java class (i.e., within the outermost enclosing {...} tokens). Inner classes are not recognized by the JScheme compiler. Any <program> elements placed within an inner class will be treated as if they are part of the outermost enclosing class. The <import> element is provided to allow JScheme code to be stored in an external source file. When the compiler encounters this element, the next string token (in quotation marks) is interpreted as the name of a text file containing JScheme source code, which is then read in as if it appeared directly within the Java source file. Using Java comments to store data that is not part of the program itself is not a new idea. Comments are used to store javadoc tags for generating class, method, and field documentation, and have also been used to store annotations for static type checking [2]. To our knowledge, this is the first time comments have been used to store source code. 3.2 Compiling embedded JScheme source code Once the JScheme source code has been placed within the Java source code, it must be compiled by the JScheme compiler. jscomp [<options>] <file>* Each <file> is the name of a Java source file (the.java) extension may be omitted). Alternatively, by using the -d option, each <file> is interpreted as a directory. Every Java file contained within the subtree rooted at that directory will be compiled. Figure 3 contains a list of the options for the jscomp compiler. jscomp : JScheme compiler Usage: jscomp [<options>] <file>* Options: --verbose, -v : verbose output --echo, -e : echo input to stdout --trace, -T : trace scanner -s : simulation only; don t modify any files -x <ext> : change extension (default=java) -b : don t save backups of originals -d [<path>] : process every.java file in <path> -D : don t store source file debug information --help, -h : help Figure 3: JScheme compiler options If a Java source file contains JScheme source, the compiler will add a static field to the end of the Java class definition. See figure 4. The compiler inserts Java source code between single-line Java comments //[ //]500 (the pair of numbers, which are equal in value, 5

6 public class Example { /*s (define (factorial n) (letrec ((fac-times (lambda (n acc) (if (= n 0) acc (fac-times (- n 1) (* acc n)))))) (fac-times n 1))) */ public static void main(string[] args) { //... } //[500 static JSRuntime rt = new JSRuntime( "2jCHx/S3PB1mA9wAc3jcoqfb51... c3h4xh6p5/ty" +"np6ay8cv9zxentnf17d87vkh7t... CLIRAwAAAACw" +"FTYq2FbYqGwTAm1UtglBNyLIRI... AAAAAAAAAAAA" ); //]500 } Figure 4: JScheme compiler output 6

7 are arbitrarily chosen by the compiler). Any old source code between such comment pairs is deleted and replaced (if necessary) by the compiler, so users should avoid modifying such source themselves. As a safety feature, before any changes are made to an existing Java source file, a backup of the file is stored in a backup directory named jscheme backups which is located in the user s home directory. This directory is specified by the Java user.home system property. Up to five backup copies of each file are retained within this directory, with a one replacing the oldest. The -b option can be used to disable this backup process. 3.3 The JScheme runtime interpreter As seen in the previous section, the JScheme compiler inserts a rather cryptic set of lines within a Java source file. At the end of the appropriate containing class, a static class variable rt of type JSRuntime is defined and initialized. The initialization string contains the compiled JScheme code, encoded using the Base64 [3] encoding scheme. When the Java class is loaded by the JVM class loader, the rt field is constructed, which causes all of the JScheme definitions and expressions contained within the <program> to be evaluated. A Java program can interact with a JScheme runtime interpreter (rt) in several ways. For instance, it can have the interpreter evaluate additional <program>s by calling the rt.eval(1) method, with its argument containing the text of the <program>. This method returns an SNode object, representing the value of the last expression evaluated. A Java program can add bindings to the current rt environment by calling the rt.define(1) method with an SNode object as its argument. This method returns an SId object containing the (unique) identifier representing the bound value. To allow JScheme code to call Java code, a Java-defined JScheme procedure can be added to the JSRuntime environment by calling the rt.define(2) method with the procedure name and an object that implements the IJavaProcedure interface. Figure 5 displays a sample program that demonstrates these features, along with the program s output. For more details on how these methods are to be used, the reader should consult the JSRuntime documentation. 4 Implementation Details In this section, we describe some of the problems encountered during development of the JScheme project and the solutions taken to solve them. 7

8 import jscheme.*; public class Example { /*s (define (factorial n) (letrec ((fac-times (lambda (n acc) (if (= n 0) acc (fac-times (- n 1) (* acc n)))))) (fac-times n 1))) */ public static void main(string[] args) { try { System.out.print("factorial 7 = "); System.out.println(rt.eval("(factorial 7)").intValue()); // add a Java-defined procedure myproc which calculates // the sum of its arguments, which are assumed to be numbers rt.define("myproc", new IJavaProcedure() { public SNode evaluateapp(jsruntime rt, SNode[] args) { int sum = 0; for (int i = 0; i < args.length; i++) sum += args[i].intvalue(); return new SNumber(sum); } }); // call myproc SNode result = rt.eval("(myproc )"); // add binding to the result SId id = rt.define(result); // print the value of the binding rt.eval("(printf \"value of "+id+" is: a n\" "+id+" )"); } catch (SchemeException e) { System.out.println(rt.toString(e, true)); } } //[500 static JSRuntime rt = new JSRuntime( "2jCHx/S3PB1mA9wAc3jcoqfb5Tkg... nvbgaaaa==" ); //]500 } Figure 5: JScheme test program and output 8

9 4.1 Internal representation of JScheme values During compilation, every JScheme expression or definition is parsed into an object we have named an SNode. These are organized into subclasses representing identifiers, symbols, values (numbers, boolean constants, characters, strings, pairs, and vectors), and procedure-related types (procedures, closures, and procedure applications). An additional SNode type, SUser, is provided to allow Java programs to wrap arbitrary Java objects within SNodes. Each SNode is evaluated with respect to a JSRuntime object. Some nodes, such as numbers and strings, evaluate to themselves. Others, such as identifiers, use the JSRuntime object to evaluate to something else. Procedures evaluate to closures, and procedure applications evaluate their arguments and use closures to evaluate their procedure s body. Compiled JScheme data includes tokens that indicate the location within a source file that produced each JScheme element. This is useful for debugging, since the interpreter maintains a stack of these tokens during evaluation and can produce a stack trace when an exception occurs. The drawback is these tokens increase the size of the compiled code (by about 50%). The tokens can be omitted by including the -D option when running the JScheme compiler. 4.2 Compiled JScheme programs The JScheme compiler parses JScheme source code, then encodes the resulting SNodes into a compact form that can be accessed by Java code. One might ask why this is necessary, since the JSRuntime class provides a method eval which does essentially the same thing. There are two main advantages to precompiling the JScheme code. First, compiling the code into SNodes is six to seven times slower than the process of extracting the SNodes from the Base64-encoded strings. Second, the JScheme source code need not appear in its uncompiled state within the compiled Java code. Compiling the JScheme code makes examining the code difficult, which may be important for proprietary software. We did not need to write a Java source code parser. A Java tokenizer was sufficient, since we only need to recognize special multiline comments, and count nested braces for detecting the start and end of (non-inner) Java classes. Both the Java and JScheme tokenizers were constructed using makedfa, a tool that constructs a deterministic finite-state automaton from a set of regular expressions [6]. We have chosen to store the compiled JScheme code as a Base64-encoded string. This is not the most efficient way to store the compiled code, since each character of the string decodes to only six bits, and since Java characters are Unicode, ten bits per character are wasted. A more memory-efficient storage scheme would be to store the compiled data as a static array of in- 9

10 tegers, in which each bit is used. We chose to use strings since they have a more compact representation in source code, since each character of source code could represent at most four bits of compiled data (if the integers were represented in hexadecimal). 4.3 Environments and closures An environment is a data type that associates a value with each element of a finite set of symbols [4]. Every JSRuntime object contains an environment to bind values to SId nodes. Procedures require a snapshot of an environment at the time a procedure is evaluated for later use when the procedure is applied; such snapshots are called closures. In JScheme, we extend an environment by wrapping the old environment within a new one. An environment consists of a hash table that contains bindings of identifiers to values, and a (possibly null) pointer to an earlier (nonextended) environment. Environments are thus immutable objects, which makes implementing closures easy. The cost of this approach is in running time efficiency: finding the value bound to an id is linear in the number of nested environments, which may be large in the case of a recursive procedure call. A more efficient method of implementing closures remains a future enhancement for the JScheme project. 5 Results To test the JScheme system, we created an Eclipse project (jstest) containing several test files. The results of each test are described below. 1. We found a scheme implementation of sets using balanced binary trees, and attempted to compile it as JScheme source code. This failed during runtime, since the standard scheme procedure zero? does not exist in JScheme. After adding this procedure to the test program, the program ran correctly. 2. We found a scheme implementation of the Eratosthenes sieve, and attempted to compile it and use it to generate the first thirty prime numbers. It failed at runtime due to the missing procedure quotient. It ran correctly once we added this procedure to the sieve code. 3. We took a small scheme program that the author wrote for an undergraduate assignment and embedded it within a Java program (Test3). Initially, the scheme would not compile, since in several places, the null list () had not been quoted. Once this was corrected, the program compiled and ran correctly. The JScheme compiler and runtime interpreter allows Java and JScheme code to interact with each other within a standard Java runtime environment. 10

11 Embedding JScheme code within Java source files simplifies the organization of a programming project, since the JScheme compiler can read, process, and modify the Java source files without creating any auxilliary object or data files. This approach is practical, since the compiled JScheme code can be stored efficiently as static data within Java classes (though a more efficient representation would be to use integers instead of strings; see section 4.2). Calling JScheme code from a Java program (and vice versa) is provided by one additional package, which requires a single import statement. There are two main drawbacks of using this approach. First, since we are compiling JScheme into data that is interpreted at runtime by a Java package, it cannot run as efficiently as code that has been compiled to be run by a faster interpreter, for instance, if the code were compiled to Java bytecode [7], or better yet, to native machine code. A second drawback is that embedding scheme source in Java comments will defeat any special IDE features that exist to aid in writing scheme code, such as syntax coloring or smart indenting (though Eclipse will perform simple brace matching in comments). Keeping the JScheme source code within its own file (with an appropriate extension that an IDE recognizes) and importing it via the #import directive may help with this problem. Future enhancements to the JScheme project might involve extending the JScheme language to include additional standard features such as continuations and tail recursion optimizations, as well as adding support for a variety of numeric data types such as floating point and complex numbers. References [1] H. Abelson et al. Revised report on the algorithmic language scheme. Higher Order Symbol. Comput., 11(1):7 105, [2] C. Flanagan, K. Rustan M. Leino, M. Lillibridge, G. Nelson, J. B. Saxe, and R. Stata. Extended static checking for java. In PLDI 02: Proceedings of the ACM SIGPLAN 2002 Conference on Programming language design and implementation, pages , New York, NY, USA, ACM. [3] N. Freed and N. Borenstein. Multipurpose internet mail extensions (mime) part one: Format of internet message bodies. Internet RFCs, [4] D. P. Friedman, C. T. Haynes, and M. Wand. Essentials of programming languages (2nd ed.). Massachusetts Institute of Technology, Cambridge, MA, USA, [5] S. Liang. Java Native Interface: Programmer s Guide and Reference. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA,

12 [6] J. Sember. Tokenizing with deterministic finite state automata, jpsember/tokenizer.html. [7] B. P. Serpette and M. Serrano. Compiling scheme to jvm bytecode: a performance study. In ICFP 02: Proceedings of the seventh ACM SIG- PLAN international conference on Functional programming, pages , New York, NY, USA, ACM. 12

Project 2: Scheme Interpreter

Project 2: Scheme Interpreter Project 2: Scheme Interpreter CSC 4101, Fall 2017 Due: 12 November 2017 For this project, you will implement a simple Scheme interpreter in C++ or Java. Your interpreter should be able to handle the same

More information

Scheme as implemented by Racket

Scheme as implemented by Racket Scheme as implemented by Racket (Simple view:) Racket is a version of Scheme. (Full view:) Racket is a platform for implementing and using many languages, and Scheme is one of those that come out of the

More information

Scheme Quick Reference

Scheme Quick Reference Scheme Quick Reference COSC 18 Fall 2003 This document is a quick reference guide to common features of the Scheme language. It is not intended to be a complete language reference, but it gives terse summaries

More information

CS 360 Programming Languages Interpreters

CS 360 Programming Languages Interpreters CS 360 Programming Languages Interpreters Implementing PLs Most of the course is learning fundamental concepts for using and understanding PLs. Syntax vs. semantics vs. idioms. Powerful constructs like

More information

Functional Programming. Pure Functional Programming

Functional Programming. Pure Functional Programming Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).

More information

Introduction to Scheme

Introduction to Scheme How do you describe them Introduction to Scheme Gul Agha CS 421 Fall 2006 A language is described by specifying its syntax and semantics Syntax: The rules for writing programs. We will use Context Free

More information

Lecture 09: Data Abstraction ++ Parsing is the process of translating a sequence of characters (a string) into an abstract syntax tree.

Lecture 09: Data Abstraction ++ Parsing is the process of translating a sequence of characters (a string) into an abstract syntax tree. Lecture 09: Data Abstraction ++ Parsing Parsing is the process of translating a sequence of characters (a string) into an abstract syntax tree. program text Parser AST Processor Compilers (and some interpreters)

More information

Scheme Quick Reference

Scheme Quick Reference Scheme Quick Reference COSC 18 Winter 2003 February 10, 2003 1 Introduction This document is a quick reference guide to common features of the Scheme language. It is by no means intended to be a complete

More information

Project 1: Scheme Pretty-Printer

Project 1: Scheme Pretty-Printer Project 1: Scheme Pretty-Printer CSC 4101, Fall 2017 Due: 7 October 2017 For this programming assignment, you will implement a pretty-printer for a subset of Scheme in either C++ or Java. The code should

More information

Scheme in Scheme: The Metacircular Evaluator Eval and Apply

Scheme in Scheme: The Metacircular Evaluator Eval and Apply Scheme in Scheme: The Metacircular Evaluator Eval and Apply CS21b: Structure and Interpretation of Computer Programs Brandeis University Spring Term, 2015 The metacircular evaluator is A rendition of Scheme,

More information

6.184 Lecture 4. Interpretation. Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson

6.184 Lecture 4. Interpretation. Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson 6.184 Lecture 4 Interpretation Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson 1 Interpretation Parts of an interpreter Arithmetic calculator

More information

A LISP Interpreter in ML

A LISP Interpreter in ML UNIVERSITY OF OSLO Department of Informatics A LISP Interpreter in ML Mandatory Assignment 1 INF3110 September 21, 2009 Contents 1 1 Introduction The purpose of this assignment is to write an interpreter,

More information

Functional Programming. Pure Functional Languages

Functional Programming. Pure Functional Languages Functional Programming Pure functional PLs S-expressions cons, car, cdr Defining functions read-eval-print loop of Lisp interpreter Examples of recursive functions Shallow, deep Equality testing 1 Pure

More information

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) CSE 413 Languages & Implementation Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1 Goals Representing programs as data Racket structs as a better way to represent

More information

Announcements. The current topic: Scheme. Review: BST functions. Review: Representing trees in Scheme. Reminder: Lab 2 is due on Monday at 10:30 am.

Announcements. The current topic: Scheme. Review: BST functions. Review: Representing trees in Scheme. Reminder: Lab 2 is due on Monday at 10:30 am. The current topic: Scheme! Introduction! Object-oriented programming: Python Functional programming: Scheme! Introduction! Numeric operators, REPL, quotes, functions, conditionals! Function examples, helper

More information

An Introduction to Scheme

An Introduction to Scheme An Introduction to Scheme Stéphane Ducasse stephane.ducasse@inria.fr http://stephane.ducasse.free.fr/ Stéphane Ducasse 1 Scheme Minimal Statically scoped Functional Imperative Stack manipulation Specification

More information

Principles of Programming Languages 2017W, Functional Programming

Principles of Programming Languages 2017W, Functional Programming Principles of Programming Languages 2017W, Functional Programming Assignment 3: Lisp Machine (16 points) Lisp is a language based on the lambda calculus with strict execution semantics and dynamic typing.

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

User-defined Functions. Conditional Expressions in Scheme

User-defined Functions. Conditional Expressions in Scheme User-defined Functions The list (lambda (args (body s to a function with (args as its argument list and (body as the function body. No quotes are needed for (args or (body. (lambda (x (+ x 1 s to the increment

More information

Scheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7

Scheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7 Scheme Textbook, Sections 13.1 13.3, 13.7 1 Functional Programming Based on mathematical functions Take argument, return value Only function call, no assignment Functions are first-class values E.g., functions

More information

6.037 Lecture 4. Interpretation. What is an interpreter? Why do we need an interpreter? Stages of an interpreter. Role of each part of the interpreter

6.037 Lecture 4. Interpretation. What is an interpreter? Why do we need an interpreter? Stages of an interpreter. Role of each part of the interpreter 6.037 Lecture 4 Interpretation Interpretation Parts of an interpreter Meta-circular Evaluator (Scheme-in-scheme!) A slight variation: dynamic scoping Original material by Eric Grimson Tweaked by Zev Benjamin,

More information

Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs. Lexical addressing

Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs. Lexical addressing Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs Lexical addressing The difference between a interpreter and a compiler is really two points on a spectrum of possible

More information

Essentials of Programming Languages Language

Essentials of Programming Languages Language Essentials of Programming Languages Language Version 5.3 August 6, 2012 The Essentials of Programming Languages language in DrRacket provides a subset of functions and syntactic forms of racket mostly

More information

CSE 341, Spring 2011, Final Examination 9 June Please do not turn the page until everyone is ready.

CSE 341, Spring 2011, Final Examination 9 June Please do not turn the page until everyone is ready. CSE 341, Spring 2011, Final Examination 9 June 2011 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.

More information

Essentials of Programming Languages Language

Essentials of Programming Languages Language Essentials of Programming Languages Language Version 6.90.0.26 April 20, 2018 The Essentials of Programming Languages language in DrRacket provides a subset of functions and syntactic forms of racket mostly

More information

Scheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G.

Scheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G. Scheme: Data CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks ggchappell@alaska.edu

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Streams, Delayed Evaluation and a Normal Order Interpreter. CS 550 Programming Languages Jeremy Johnson

Streams, Delayed Evaluation and a Normal Order Interpreter. CS 550 Programming Languages Jeremy Johnson Streams, Delayed Evaluation and a Normal Order Interpreter CS 550 Programming Languages Jeremy Johnson 1 Theme This lecture discusses the stream model of computation and an efficient method of implementation

More information

Scheme Tutorial. Introduction. The Structure of Scheme Programs. Syntax

Scheme Tutorial. Introduction. The Structure of Scheme Programs. Syntax Scheme Tutorial Introduction Scheme is an imperative language with a functional core. The functional core is based on the lambda calculus. In this chapter only the functional core and some simple I/O is

More information

Principles of Programming Languages

Principles of Programming Languages Principles of Programming Languages Lesson 14 Type Checking Collaboration and Management Dana Fisman www.cs.bgu.ac.il/~ppl172 1 Type Checking We return to the issue of type safety we discussed informally,

More information

Functional Programming. Pure Functional Languages

Functional Programming. Pure Functional Languages Functional Programming Pure functional PLs S-expressions cons, car, cdr Defining functions read-eval-print loop of Lisp interpreter Examples of recursive functions Shallow, deep Equality testing 1 Pure

More information

A Brief Introduction to Scheme (II)

A Brief Introduction to Scheme (II) A Brief Introduction to Scheme (II) Philip W. L. Fong pwlfong@cs.uregina.ca Department of Computer Science University of Regina Regina, Saskatchewan, Canada Lists Scheme II p.1/29 Lists Aggregate data

More information

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going

More information

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts

More information

COP4020 Programming Assignment 1 - Spring 2011

COP4020 Programming Assignment 1 - Spring 2011 COP4020 Programming Assignment 1 - Spring 2011 In this programming assignment we design and implement a small imperative programming language Micro-PL. To execute Mirco-PL code we translate the code to

More information

SCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015

SCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015 SCHEME 7 COMPUTER SCIENCE 61A October 29, 2015 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

CSCC24 Functional Programming Scheme Part 2

CSCC24 Functional Programming Scheme Part 2 CSCC24 Functional Programming Scheme Part 2 Carolyn MacLeod 1 winter 2012 1 Based on slides from Anya Tafliovich, and with many thanks to Gerald Penn and Prabhakar Ragde. 1 The Spirit of Lisp-like Languages

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

;;; Determines if e is a primitive by looking it up in the primitive environment. ;;; Define indentation and output routines for the output for

;;; Determines if e is a primitive by looking it up in the primitive environment. ;;; Define indentation and output routines for the output for Page 1/11 (require (lib "trace")) Allow tracing to be turned on and off (define tracing #f) Define a string to hold the error messages created during syntax checking (define error msg ""); Used for fancy

More information

C311 Lab #3 Representation Independence: Representation Independent Interpreters

C311 Lab #3 Representation Independence: Representation Independent Interpreters C311 Lab #3 Representation Independence: Representation Independent Interpreters Will Byrd webyrd@indiana.edu February 5, 2005 (based on Professor Friedman s lecture on January 29, 2004) 1 Introduction

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

CSE 413 Midterm, May 6, 2011 Sample Solution Page 1 of 8

CSE 413 Midterm, May 6, 2011 Sample Solution Page 1 of 8 Question 1. (12 points) For each of the following, what value is printed? (Assume that each group of statements is executed independently in a newly reset Scheme environment.) (a) (define x 1) (define

More information

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d) CMSC 330: Organization of Programming Languages Tail Calls A tail call is a function call that is the last thing a function does before it returns let add x y = x + y let f z = add z z (* tail call *)

More information

Lecture #24: Programming Languages and Programs

Lecture #24: Programming Languages and Programs Lecture #24: Programming Languages and Programs A programming language is a notation for describing computations or processes. These range from low-level notations, such as machine language or simple hardware

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited CMSC 330: Organization of Programming Languages Type Systems, Names & Binding Topics Covered Thus Far Programming languages Syntax specification Regular expressions Context free grammars Implementation

More information

Semantic Analysis. Lecture 9. February 7, 2018

Semantic Analysis. Lecture 9. February 7, 2018 Semantic Analysis Lecture 9 February 7, 2018 Midterm 1 Compiler Stages 12 / 14 COOL Programming 10 / 12 Regular Languages 26 / 30 Context-free Languages 17 / 21 Parsing 20 / 23 Extra Credit 4 / 6 Average

More information

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Statically vs. Dynamically typed languages

More information

CS 415 Midterm Exam Spring SOLUTION

CS 415 Midterm Exam Spring SOLUTION CS 415 Midterm Exam Spring 2005 - SOLUTION Name Email Address Student ID # Pledge: This exam is closed note, closed book. Questions will be graded on quality of answer. Please supply the best answer you

More information

Typed Racket: Racket with Static Types

Typed Racket: Racket with Static Types Typed Racket: Racket with Static Types Version 5.0.2 Sam Tobin-Hochstadt November 6, 2010 Typed Racket is a family of languages, each of which enforce that programs written in the language obey a type

More information

Principles of Programming Languages Topic: Functional Programming Professor L. Thorne McCarty Spring 2003

Principles of Programming Languages Topic: Functional Programming Professor L. Thorne McCarty Spring 2003 Principles of Programming Languages Topic: Functional Programming Professor L. Thorne McCarty Spring 2003 CS 314, LS, LTM: Functional Programming 1 Scheme A program is an expression to be evaluated (in

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Type Systems, Names and Binding CMSC 330 - Spring 2013 1 Topics Covered Thus Far! Programming languages Ruby OCaml! Syntax specification Regular expressions

More information

Streams. CS21b: Structure and Interpretation of Computer Programs Spring Term, 2004

Streams. CS21b: Structure and Interpretation of Computer Programs Spring Term, 2004 Streams CS21b: Structure and Interpretation of Computer Programs Spring Term, 2004 We ve already seen how evaluation order can change behavior when we program with state. Now we want to investigate how

More information

Python in 10 (50) minutes

Python in 10 (50) minutes Python in 10 (50) minutes https://www.stavros.io/tutorials/python/ Python for Microcontrollers Getting started with MicroPython Donald Norris, McGrawHill (2017) Python is strongly typed (i.e. types are

More information

Data Abstraction. An Abstraction for Inductive Data Types. Philip W. L. Fong.

Data Abstraction. An Abstraction for Inductive Data Types. Philip W. L. Fong. Data Abstraction An Abstraction for Inductive Data Types Philip W. L. Fong pwlfong@cs.uregina.ca Department of Computer Science University of Regina Regina, Saskatchewan, Canada Introduction This lecture

More information

A Small Interpreted Language

A Small Interpreted Language A Small Interpreted Language What would you need to build a small computing language based on mathematical principles? The language should be simple, Turing equivalent (i.e.: it can compute anything that

More information

The role of semantic analysis in a compiler

The role of semantic analysis in a compiler Semantic Analysis Outline The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

Why do we need an interpreter? SICP Interpretation part 1. Role of each part of the interpreter. 1. Arithmetic calculator.

Why do we need an interpreter? SICP Interpretation part 1. Role of each part of the interpreter. 1. Arithmetic calculator. .00 SICP Interpretation part Parts of an interpreter Arithmetic calculator Names Conditionals and if Store procedures in the environment Environment as explicit parameter Defining new procedures Why do

More information

Parsing Scheme (+ (* 2 3) 1) * 1

Parsing Scheme (+ (* 2 3) 1) * 1 Parsing Scheme + (+ (* 2 3) 1) * 1 2 3 Compiling Scheme frame + frame halt * 1 3 2 3 2 refer 1 apply * refer apply + Compiling Scheme make-return START make-test make-close make-assign make- pair? yes

More information

Ways to implement a language

Ways to implement a language Interpreters Implemen+ng PLs Most of the course is learning fundamental concepts for using PLs Syntax vs. seman+cs vs. idioms Powerful constructs like closures, first- class objects, iterators (streams),

More information

Principles of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004

Principles of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004 Principles of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004 CS 314, LS,BR,LTM: Scope and Memory 1 Review Functions as first-class objects What can you do with an integer?

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

ALISP interpreter in Awk

ALISP interpreter in Awk ALISP interpreter in Awk Roger Rohrbach 1592 Union St., #94 San Francisco, CA 94123 January 3, 1989 ABSTRACT This note describes a simple interpreter for the LISP programming language, written in awk.

More information

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

Racket: Modules, Contracts, Languages

Racket: Modules, Contracts, Languages Racket: Modules, Contracts, Languages Advanced Functional Programming Jean-Noël Monette November 2013 1 Today Modules are the way to structure larger programs in smaller pieces. Modules can import and

More information

Functions & First Class Function Values

Functions & First Class Function Values Functions & First Class Function Values PLAI 1st ed Chapter 4, PLAI 2ed Chapter 5 The concept of a function is itself very close to substitution, and to our with form. Consider the following morph 1 {

More information

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures Dan Grossman Fall 2014 Hi! I m not Hal J I love this stuff and have taught

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Scheme: Strings Scheme: I/O

Scheme: Strings Scheme: I/O Scheme: Strings Scheme: I/O CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Wednesday, April 5, 2017 Glenn G. Chappell Department of Computer Science University of

More information

Box-and-arrow Diagrams

Box-and-arrow Diagrams Box-and-arrow Diagrams 1. Draw box-and-arrow diagrams for each of the following statements. What needs to be copied, and what can be referenced with a pointer? (define a ((squid octopus) jelly sandwich))

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Parser Design. Neil Mitchell. June 25, 2004

Parser Design. Neil Mitchell. June 25, 2004 Parser Design Neil Mitchell June 25, 2004 1 Introduction A parser is a tool used to split a text stream, typically in some human readable form, into a representation suitable for understanding by a computer.

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017 SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

CS 61A Interpreters, Tail Calls, Macros, Streams, Iterators. Spring 2019 Guerrilla Section 5: April 20, Interpreters.

CS 61A Interpreters, Tail Calls, Macros, Streams, Iterators. Spring 2019 Guerrilla Section 5: April 20, Interpreters. CS 61A Spring 2019 Guerrilla Section 5: April 20, 2019 1 Interpreters 1.1 Determine the number of calls to scheme eval and the number of calls to scheme apply for the following expressions. > (+ 1 2) 3

More information

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

Comp 311: Sample Midterm Examination

Comp 311: Sample Midterm Examination Comp 311: Sample Midterm Examination October 29, 2007 Name: Id #: Instructions 1. The examination is closed book. If you forget the name for a Scheme operation, make up a name for it and write a brief

More information

Java: framework overview and in-the-small features

Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; } Ex: The difference between Compiler and Interpreter The interpreter actually carries out the computations specified in the source program. In other words, the output of a compiler is a program, whereas

More information

INTRODUCTION TO SCHEME

INTRODUCTION TO SCHEME INTRODUCTION TO SCHEME PRINCIPLES OF PROGRAMMING LANGUAGES Norbert Zeh Winter 2019 Dalhousie University 1/110 SCHEME: A FUNCTIONAL PROGRAMMING LANGUAGE Functions are first-class values: Can be passed as

More information

Functions and Recursion. Dr. Philip Cannata 1

Functions and Recursion. Dr. Philip Cannata 1 Functions and Recursion Dr. Philip Cannata 1 10 High Level Languages This Course Java (Object Oriented) Jython in Java Relation ASP RDF (Horn Clause Deduction, Semantic Web) Dr. Philip Cannata 2 let transformation,

More information

CS 6353 Compiler Construction Project Assignments

CS 6353 Compiler Construction Project Assignments CS 6353 Compiler Construction Project Assignments In this project, you need to implement a compiler for a language defined in this handout. The programming language you need to use is C or C++ (and the

More information

Scheme->C Index to the Report on the Algorithmic Language Scheme 15 March 1993

Scheme->C Index to the Report on the Algorithmic Language Scheme 15 March 1993 Scheme->C Index to the Report on the Algorithmic Language Scheme 15 March 1993 Implementation Notes bit-and bit-lsh bit-not bit-or bit-rsh bit-xor Scheme->C is an implementation of the language c-byte-ref

More information

CPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia

CPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia CPL 2016, week 10 Clojure functional core Oleg Batrashev Institute of Computer Science, Tartu, Estonia April 11, 2016 Overview Today Clojure language core Next weeks Immutable data structures Clojure simple

More information

Name EID. (calc (parse '{+ {with {x {+ 5 5}} {with {y {- x 3}} {+ y y} } } z } ) )

Name EID. (calc (parse '{+ {with {x {+ 5 5}} {with {y {- x 3}} {+ y y} } } z } ) ) CS 345 Spring 2010 Midterm Exam Name EID 1. [4 Points] Circle the binding instances in the following expression: (calc (parse '+ with x + 5 5 with y - x 3 + y y z ) ) 2. [7 Points] Using the following

More information

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8 Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns

More information

Lecture08: Scope and Lexical Address

Lecture08: Scope and Lexical Address Lecture08: Scope and Lexical Address Free and Bound Variables (EOPL 1.3.1) Given an expression E, does a particular variable reference x appear free or bound in that expression? Definition: A variable

More information

4 Programming Fundamentals. Introduction to Programming 1 1

4 Programming Fundamentals. Introduction to Programming 1 1 4 Programming Fundamentals Introduction to Programming 1 1 Objectives At the end of the lesson, the student should be able to: Identify the basic parts of a Java program Differentiate among Java literals,

More information

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; } Ex: The difference between Compiler and Interpreter The interpreter actually carries out the computations specified in the source program. In other words, the output of a compiler is a program, whereas

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

The Typed Racket Guide

The Typed Racket Guide The Typed Racket Guide Version 5.3.6 Sam Tobin-Hochstadt and Vincent St-Amour August 9, 2013 Typed Racket is a family of languages, each of which enforce

More information

Functional Programming - 2. Higher Order Functions

Functional Programming - 2. Higher Order Functions Functional Programming - 2 Higher Order Functions Map on a list Apply Reductions: foldr, foldl Lexical scoping with let s Functional-11, CS5314, Sp16 BGRyder 1 Higher Order Functions Functions as 1st class

More information

CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018

CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018 CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2018 Typical workflow concrete syntax (string) "(fn x => x + x) 4" Parsing Possible errors / warnings

More information

Below are example solutions for each of the questions. These are not the only possible answers, but they are the most common ones.

Below are example solutions for each of the questions. These are not the only possible answers, but they are the most common ones. 6.001, Fall Semester, 2002 Quiz II Sample solutions 1 MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs

More information

Structure and Interpretation of Computer Programs

Structure and Interpretation of Computer Programs CS 6A Spring 203 Structure and Interpretation of Computer Programs Final Solutions INSTRUCTIONS You have 3 hours to complete the exam. The exam is closed book, closed notes, closed computer, closed calculator,

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

CS 415 Midterm Exam Fall 2003

CS 415 Midterm Exam Fall 2003 CS 415 Midterm Exam Fall 2003 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Questions will be graded on quality of answer. Please supply the best answer you can to

More information

Functional Languages. Hwansoo Han

Functional Languages. Hwansoo Han Functional Languages Hwansoo Han Historical Origins Imperative and functional models Alan Turing, Alonzo Church, Stephen Kleene, Emil Post, etc. ~1930s Different formalizations of the notion of an algorithm

More information

Modern Programming Languages. Lecture LISP Programming Language An Introduction

Modern Programming Languages. Lecture LISP Programming Language An Introduction Modern Programming Languages Lecture 18-21 LISP Programming Language An Introduction 72 Functional Programming Paradigm and LISP Functional programming is a style of programming that emphasizes the evaluation

More information