CS326 Programming Languages, Aug23 1999

Notes for Aug 23

Administration

Scheme


Programming Languages:


The interpreter for a programming language 
is just another program

Understanding interpreters key to understanding
the programming languages in existence and a
source of great power.

1. You will implement interpreters 
	structures interaction with system

2. Large systems will have interpreter type pieces
	HCI, GRAPHICS,..

3. Programming techniques that manipulate the structure
	of the language are increasing.
	C++/OOP/Java...



	Scheme

Statements: PL constructs evaluated for effect  
	ex: =, cin, cout, ...

STATEMENT ORIENTED languages


Expressions: PL constructs evaluated to obtain values
	ex: 4 + 5, x - y, ...RHS of assignments

expressed values: set of data that can be 
	returned by expressions in a language

FUNCTIONAL languages


Scheme is expression oriented
	Scheme ==> definitions | expressions

No statements in scheme!





Literals/Constants: 4, #t, #f, "this is a string", ...

Variable references: 
 The value of a variable reference is the value
currently associated with, or bound to, the variable

A variable DENOTES the value of its binding.

DENOTED VALUES (of a PL):
	 Data that can be bound to variables

Scheme : denoted values == expressed values

No assignment statements



Identifiers

Letters, digits, NOT CASE SENSITIVE

Scheme is more permissive

+, -, /, two+three, zero?, a-very-long-indentifier

all legal.

no parens or spaces in names.

Keywords: define, if, ...

Standard Bindings: +, zero?, /, *, ....




functions and procedures

	no difference in scheme

We will use function to refer to abstract 
mathemematical objects

procedure calls:
Normally:
	p(2, 3)

Scheme:

	(p 2 3)

apply p to 2 and 3
procedure calls ==> procedure applications

(operator operand1, operand2, ..., operandN)

	arguments, parameters, formal parameters.


Operator subexpression is evaluated to obtain
a procedure

Operand subexpressions are evaluated to obtain
arguments before invoking the procedure

The order of evaluation of operands is 
NOT SPECIFIED in scheme.

N can be any number of operands (including 0)

(+ x ( p 2 3))

procedure calls can contain expressions.

((g 2) 3 4)

procedures that return procedures are called 
higher-order-procedures



Most operations can be accomplished with procedure calls.

However for those that cannot be done with proc calls
We need a SPECIAL FORM.

Binding variable x to 3

(define x 3)

General:

(define variable expression)

Each special form:

	Keyword
	sequencing rule
	

define:
	expression evaluated first
	variable is bound to value of expression




Sushil Louis
Last modified: Tue Aug 24 15:29:29 PDT 1999