324-lecture9B - Principles of Programming Languages...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Principles of Programming Languages Principles of Programming Languages Lecture 9B Lecture 9B University of Toronto Wael Aboulsaadat Wael Aboulsaadat [email protected] [email protected] http://portal.utoronto.ca/ 1 SC324: Principles of Programming Languages unctional Programming Languages (FPL) unctional Programming Languages (FPL) • “Can programming be librated from the Von Neumann style?” John Backus • Problems with Imperative programming languages: – Von Neumann bottle neck (i.e. fetching words across bus) • Assignment – Side-effects RAM CPU University of Toronto – State-based transformation • FPL alternative: – Goal? mimic mathematical functions to the greatest extent possible – How? Use calculus for the computation – The program is a mathematical function • FPL-based solutions: – Hardware: Symbolics Machine, TI Explorer… – Software: Lisp (Scheme && Racket) , ML, Haskell, Miranda … ALU System Bus 2 SC324: Principles of Programming Languages PL: Mathematical PL: Mathematical v.s v.s. Imperative . Imperative • Recall: how do imperative functions work? – Specify a sequence of operations on values in memory to produce a value – Evaluation is controlled by sequencing and iteration • Why are mathematical functions different? – The value is defined and not produced – Evaluation order is controlled by recursion and conditional expressions University of Toronto • Example: – Write a procedure to implement the following function f (x) = x * x / 3 • Imperative: procedure float foo( var int x ) int product; float quotient ; product := x * x; quotient := product/ 3; return quotient; • Functional: ?? 3 SC324: Principles of Programming Languages PL: Desiderata PL: Desiderata 1. A program consists of: – Function definitions – Function calls – There is no other structure. 2. Control flow: University of Toronto – Recursion and function application is the only way to achieve repetition 3. No assignment – Values are bound to values only through parameter association 4 SC324: Principles of Programming Languages 4. No side effects – A function may not change its parameters – A function cannot do input or output 5. No variable declaration – No explicit typing PL: Desiderata PL: Desiderata...
View Full Document

This document was uploaded on 08/02/2011.

Page1 / 18

324-lecture9B - Principles of Programming Languages...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online