210 likes | 514 Views
SCHEME. Scheme is elegant, clear, small, and powerful programming language. It is a dialect of LISP and can be classified as a semi-functional programming language. Scheme is based on a formal model the lambda calculus. History of Scheme. History of Scheme.
E N D
SCHEME • Scheme is elegant, clear, small, and powerful programming language. It is a dialect of LISP and can be classified as a semi-functional programming language. • Scheme is based on a formal model the lambda calculus.
History of Scheme • 1975 Scheme came into existence as a “toy'' Lisp interpreter that Guy Steele and Gerald Sussman wrote to study some aspects of Carl Hewitt's theory of actors, an object-oriented computational paradigm. • 1978 Rabbit -1st scheme compiler by Guy Steele Jr. It was used at the Massachusetts Institute of Technology AI department for reasearching new semantic concepts in programming language.
History (cont’n) • Scheme rapidly became popular not only among groups interested in the theoretical and mathematical aspects of programming languages, but also as a tool for research and as the basis for computer science curricula at the universities and colleges
History (cont) • Scheme standardization is an ongoing process. Today Reports are now written by an informal group of “Scheme Authors”. They communicate on a regular basis, and new features must be decided on unanimously by the authors. • This ensures the language remains relatively stable and small.
Features of Scheme • Functions are first class citizens • stored in a variable or a list • passed to another function • returned from another function • Scheme's philosophy is unashamedly Minimalist • Its goal is not to pile feature upon feature, but to remove weaknesses and restrictions that make new features appear necessary.
Features (cont) • First variety of Lisp to use lexical variable scoping exclusively • the scope of certain variables is determined according to its position in program code • Like Lisp, Scheme supports garbage collection of unreferenced data.
Features(cont) • Listing capabilities - It uses lists as the primary data structure. • (a (b (c d))) • Scheme has very little syntax compared to many other programming languages.
Some Disadvantages • Things that are simple in other languages tend to be hard in Scheme, yet some simple Scheme tricks are hard to do in other languages. • Scheme is not standardized beyond its core. • Functions that exist in one Scheme implementation do not need to exist in another or may have a completely different name and/or interface
Disadvantages (cont) • One of the drawbacks of Scheme is that they are dynamically typed.This means that functions are written without saying what type of arguments they expect. - If the wrong type of value is passed to a function, the error is only detected at run-time when an operation is applied to a value that is incorrect (e.g., adding a string to a number or subtracting one from a function).
Hello World • HELLO WORLD (BEGIN (display “Hello,World”) (newline))
Hello World • BEGIN –evaluates the expessions sequentially from left to right, and the value of the last expression is returned. • (display obj) - standard output for printing to screen
Factorial • (define (fact n) (if (zero? n) 1 (* n (fact (- n 1)))))
Length of Argument in List • (define (len x) (if (null? x) 0 ;else (+ 1 (len (cdr x)))))
Lexical Scoping (define counter 50) (define (inc-counter) (set! counter (+ 1 counter)) counter) (let ((counter 100)) (display (inc-counter)) (newline) (display counter) (newline) (display (inc-counter))(newline))
Let specifies binding of variables to a value - The variables bound by let are visible only within the body of the let - The variables are bound to fresh locations holding the results • let((variable init) ...) expression expression
Sample Scheme Programs BRL. The "Beautiful Report Language"; a framework for building server-side web applications. See http://sourceforge.net/projects/brl/. Naughty Dog. The game developer Naughty Dog Inc have used Scheme in the development of a several of their games. See http://www.naughtydog.com/. Siag Office. A free Office package for Unix that features Scheme as one of its extension languages. See http://siag.nu/index.shtml. ·Scribe. A text processor for writing technical documents and producing output in a variety of formats. See http://www-sop.inria.fr/mimosa/fp/Scribe/. JACAL. An interactive symbolic mathematics program. See http://swissnet.ai.mit.edu/~jaffer/JACAL.html.
Some Scheme Implementations • Bigloo http://www-sop.inria.fr/mimosa/fp/Bigloo/ • Chez Scheme http://www.scheme.com/ • DrScheme http://drscheme.org • Chicken http://www.call-with-current-continuation.org/ • EdScheme http://www.schemers.com/ • Guile http://www.gnu.org/software/guile/ • JScheme http://jscheme.sourceforge.net/ • Luna http://sourceforge.net/projects/luna-scheme/ • MIT Scheme http://www.swiss.ai.mit.edu/projects/scheme/ • MScheme http://drscheme.org • OpenScheme http://www.open-scheme.com/
Links • Scheme Documentations • IEEE:http://standards.ieee.org/reading/ieee/std_public/description/busarch/1178-990_desc.htm • R5RS:http://schemers.org/Documents/Standards/R5RS/