Lexical Scope and Function Closures +Closures.Rkt

Total Page:16

File Type:pdf, Size:1020Kb

Lexical Scope and Function Closures +Closures.Rkt CS 251 SpringFall 2019 2020 Principles of of Programming Programming Languages Languages λ Ben Wood Lexical Scope and Function Closures +closures.rkt https://cs.wellesley.edu/~cs251/s20/ Lexical Scope and Function Closures 1 Topics • Lexical vs dynamic scope • Closures implement lexical scope. • Design considerations: why lexical scope? • Relevant design dimensions Lexical Scope and Function Closures 2 A question of scope (warmup) (define x 1) (define f (lambda (y) (+ x y))) (define z (let ([x 2] [y 3]) (f (+ x y)))) What is the argument value passed to this function application? Lexical Scope and Function Closures 3 A question of scope (define x 1) (define f (lambda (y) (+ x y))) (define z (let ([x 2] [y 3]) (f (+ x y)))) What is the value of x when this function body is evaluated for this function application? Lexical Scope and Function Closures 4 A question of free variables A variable, x, is free in an expression, e, if x is referenced in e outside the scope of any binding of x within e. x is a free variable (define x 1) of the lambda expression. (define f (lambda (y) (+ x y))) (define z (let ([x 2] [y 3]) (f (+ x y)))) To what bindings do free variables of a function refer when the function is applied? Lexical Scope and Function Closures 5 Answer 1: lexical (static) scope A variable, x, is free in an expression, e, if x is referenced in e outside the scope of any binding of x within e. x is a free variable (define x 1) of the lambda expression. (define f (lambda (y) (+ x y))) (define z (let ([x 2] [y 3]) (f (+ x y)))) Free variables of a function refer to bindings in the environment where the function is defined, regardless of where it is applied. Lexical Scope and Function Closures 6 Answer 2: dynamic scope A variable, x, is free in an expression, e, if x is referenced in e outside the scope of any binding of x within e. x is a free variable (define x 1) of the lambda expression. (define f (lambda (y) (+ x y))) (define z (let ([x 2] [y 3]) (f (+ x y)))) Free variables of a function refer to bindings in the environment where the function is applied, regardless of where it is defined. Lexical Scope and Function Closures 7 Answer 2: dynamic scope A variable, x, is free in an expression, e, if x is referenced in e outside the scope of any binding of x within e. x is a free variable (define x 1) of the lambda expression. (define f (lambda (y) (+ x y))) (define z (let ([x 2] [y 3]) (f (+ x y)))) Free variables of a function refer to bindings in the environment where the function is applied, regardless of where it is defined. Lexical Scope and Function Closures 8 Closures implement lexical scope. Closures allow functions to use any binding in the environment where the function is defined, regardless of where it is applied. Lexical Scope and Function Closures 9 Anonymous function definition expressions Syntax: (lambda (x1 … xn) e) Week 1 – parameters: x1 through xn are identifiers – body: e is any expression Evaluation: 1. The result is a function closure, ⟨E, (lambda (x1 … xn) e)⟩, holding the current environment, E, and the function. [closure] E ⊢ (lambda (x1 … xn) e) ↓ ⟨E, (lambda (x1 … xn) e)⟩ Note: – An anonymous function definition is an expression. – A function closure is a new kind of value. Closures are not expressions. – This is a definition, not a call. The body, e, is not evaluated now. – lambda from the λ-calculus. Lexical Scope and Function Closures 10 Function application (call) Syntax: (e0 e1 ... en) Week 1 Evaluation: 1. Under the current dynamic environment, E, evaluate e0 through en to values v0, …, vn. 2. If v0 is a function closure of n arguments, ⟨E', (lambda (x1 … xn) e)⟩ then The result is the result of evaluating the closure body, e, under the closure environment, E', extended with argument bindings: x1 ⟼ v1, …, xn ⟼ vn. Otherwise, there is a type error. Functions 11 Function application (call) Week 1 Syntax: (e0 e1 … en) Evaluation: E ⊢ e0 ↓ ⟨E', (lambda (x1 … xn) e)⟩ E ⊢ e1 ↓ v1 … E ⊢ en ↓ vn x1 ⟼ v1, …, xn ⟼ vn, E' ⊢ e ↓ v [apply] E ⊢ (e0 e1 … en) ↓ v Functions 12 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value def (define x 1) Current evaluation step: (definedef (f y) (let ([x (+ y 1)]) Current environment: (lambda (z) (+ x y z)) ) (define z (let ([x 3] [g (f 4)] [y 5]) (g 6) )) Lexical Scope and Function Closures 13 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 def (define (f y) (letdef ([x (+ y 1)]) (lambda (z) (+ x y z)) ) (define z (let ([x 3] [g (f 4)] [y 5]) (g 6) )) Lexical Scope and Function Closures 14 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 (define (f y) (lambda (y) f env (let ([x (+ y 1)]) def (lambda (z) (let ([x (+ y 1)]) (+ x y z)) ) ) (lambda (z) (+ x y z)) ) (define z (let ([x 3] [g (f 4)] [y 5]) def (g 6) )) Lexical Scope and Function Closures 15 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 (define (f y) (lambda (y) f env (let ([x (+ y 1)]) def (lambda (z) (let ([x (+ y 1)]) (+ x y z)) ) ) let (lambda (z) (+ x y z)) ) (define z (let ([x 3] [g (f 4)] [y 5]) def let (g 6) )) Lexical Scope and Function Closures 16 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 (define (f y) (lambda (y) f env (let ([x (+ y 1)]) def (lambda (z) (let ([x (+ y 1)]) (+ x y z)) ) ) (lambda (z) (+ x y z)) ) x 3 (define z (let ([x 3] let [g (f 4)] [y 5]) def let (g 6) )) Lexical Scope and Function Closures 17 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 app (define (f y) (lambda (y) app f env (let ([x (+ y 1)]) def (lambda (z) (let ([x (+ y 1)]) (+ x y z)) ) ) (lambda (z) (+ x y z)) ) app y 4 x 3 (define z (let ([x 3] let [g (f 4)] [y 5]) def let (g 6) )) Lexical Scope and Function Closures 18 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 (define (f y) (lambda (y) f env (let ([x (+ y 1)]) def (lambda (z) (let ([x (+ y 1)]) app (+ x y z)) ) ) (lambda (z) app (+ x y z)) ) y 4 x 3 let (define z (let ([x 3] x 5 [g (f 4)] app [y 5]) def let (g 6) )) Lexical Scope and Function Closures 19 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 (define (f y) (lambda (y) f env (let ([x (+ y 1)]) def (lambda (z) (let ([x (+ y 1)]) (+ x y z)) ) ) (lambda (z) y 4 (+ x y z)) ) app x 3 let (define z (let ([x 3] x 5 [g (f 4)] app app [y 5]) def (lambda (z) env let (+ x y z)) (g 6) )) Lexical Scope and Function Closures 20 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 (define (f y) (lambda (y) f env (let ([x (+ y 1)]) def (lambda (z) (let ([x (+ y 1)]) (+ x y z)) ) ) (lambda (z) (+ x y z)) ) y 4 x 3 (define z (let ([x 3] x 5 [g (f 4)] [y 5]) g def let (lambda (z) env (+ x y z)) (g 6) )) let Lexical Scope and Function Closures 21 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 (define (f y) (lambda (y) f env (let ([x (+ y 1)]) def (lambda (z) (let ([x (+ y 1)]) (+ x y z)) ) ) (lambda (z) (+ x y z)) ) y 4 x 3 (define z (let ([x 3] x 5 [g (f 4)] [y 5]) g def (lambda (z) env (+ x y z)) (g 6) )) y 5 let let Lexical Scope and Function Closures 22 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 (define (f y) (lambda (y) f env (let ([x (+ y 1)]) def (lambda (z) (let ([x (+ y 1)]) (+ x y z)) ) ) (lambda (z) (+ x y z)) ) y 4 app x 3 (define z (let ([x 3] x 5 [g (f 4)] [y 5]) g def (lambda (z) env (+ x y z)) (g 6) )) y 5 app let z 6 app let Lexical Scope and Function Closures 23 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 (define (f y) (lambda (y) f env (let ([x (+ y 1)]) def (lambda (z) (let ([x (+ y 1)]) (+ x y z)) ) ) (lambda (z) (+ x y z)) ) y 4 x 3 (define z (let ([x 3] x 5 [g (f 4)]app [y 5]) g def (lambda (z) env (+ x y z)) (g 6) )) y 5 let z 6 app app let 15 Lexical Scope and Function Closures 24 env pointer Example: shows env structure, by pointing to “rest of environment” returning a function binding maps variable name to value (define x 1) x 1 (define (f y) (lambda (y) f env (let ([x (+ y 1)]) (lambda (z) (let ([x (+ y 1)]) (+ x y z)) ) ) (lambda (z) (+ x y z)) ) y 4 x 3 (define z (let ([x 3] x 5 [g (f 4)] g [y 5]) (lambda (z) env (+ x y z)) def (g 6) )) y 5 z 6 z 15 def Lexical Scope and Function Closures 25 Debrief 1.
Recommended publications
  • Bringing GNU Emacs to Native Code
    Bringing GNU Emacs to Native Code Andrea Corallo Luca Nassi Nicola Manca [email protected] [email protected] [email protected] CNR-SPIN Genoa, Italy ABSTRACT such a long-standing project. Although this makes it didactic, some Emacs Lisp (Elisp) is the Lisp dialect used by the Emacs text editor limitations prevent the current implementation of Emacs Lisp to family. GNU Emacs can currently execute Elisp code either inter- be appealing for broader use. In this context, performance issues preted or byte-interpreted after it has been compiled to byte-code. represent the main bottleneck, which can be broken down in three In this work we discuss the implementation of an optimizing com- main sub-problems: piler approach for Elisp targeting native code. The native compiler • lack of true multi-threading support, employs the byte-compiler’s internal representation as input and • garbage collection speed, exploits libgccjit to achieve code generation using the GNU Com- • code execution speed. piler Collection (GCC) infrastructure. Generated executables are From now on we will focus on the last of these issues, which con- stored as binary files and can be loaded and unloaded dynamically. stitutes the topic of this work. Most of the functionality of the compiler is written in Elisp itself, The current implementation traditionally approaches the prob- including several optimization passes, paired with a C back-end lem of code execution speed in two ways: to interface with the GNU Emacs core and libgccjit. Though still a work in progress, our implementation is able to bootstrap a func- • Implementing a large number of performance-sensitive prim- tional Emacs and compile all lexically scoped Elisp files, including itive functions (also known as subr) in C.
    [Show full text]
  • An Evaluation of Go and Clojure
    An evaluation of Go and Clojure A thesis submitted in partial satisfaction of the requirements for the degree Bachelors of Science in Computer Science Fall 2010 Robert Stimpfling Department of Computer Science University of Colorado, Boulder Advisor: Kenneth M. Anderson, PhD Department of Computer Science University of Colorado, Boulder 1. Introduction Concurrent programming languages are not new, but they have been getting a lot of attention more recently due to their potential with multiple processors. Processors have gone from growing exponentially in terms of speed, to growing in terms of quantity. This means processes that are completely serial in execution will soon be seeing a plateau in performance gains since they can only rely on one processor. A popular approach to using these extra processors is to make programs multi-threaded. The threads can execute in parallel and use shared memory to speed up execution times. These multithreaded processes can significantly speed up performance, as long as the number of dependencies remains low. Amdahl‘s law states that these performance gains can only be relative to the amount of processing that can be parallelized [1]. However, the performance gains are significant enough to be looked into. These gains not only come from the processing being divvied up into sections that run in parallel, but from the inherent gains from sharing memory and data structures. Passing new threads a copy of a data structure can be demanding on the processor because it requires the processor to delve into memory and make an exact copy in a new location in memory. Indeed some studies have shown that the problem with optimizing concurrent threads is not in utilizing the processors optimally, but in the need for technical improvements in memory performance [2].
    [Show full text]
  • Programming with GNU Emacs Lisp
    Programming with GNU Emacs Lisp William H. Mitchell (whm) Mitchell Software Engineering (.com) GNU Emacs Lisp Programming Slide 1 Copyright © 2001-2008 by William H. Mitchell GNU Emacs Lisp Programming Slide 2 Copyright © 2001-2008 by William H. Mitchell Emacs Lisp Introduction A little history GNU Emacs Lisp Programming Slide 3 Copyright © 2001-2008 by William H. Mitchell Introduction GNU Emacs is a full-featured text editor that contains a complete Lisp system. Emacs Lisp is used for a variety of things: • Complete applications such as mail and news readers, IM clients, calendars, games, and browsers of various sorts. • Improved interfaces for applications such as make, diff, FTP, shells, and debuggers. • Language-specific editing support. • Management of interaction with version control systems such as CVS, Perforce, SourceSafe, and StarTeam. • Implementation of Emacs itself—a substantial amount of Emacs is written in Emacs Lisp. And more... GNU Emacs Lisp Programming Slide 4 Copyright © 2001-2008 by William H. Mitchell A little history1 Lisp: John McCarthy is the father of Lisp. The name Lisp comes from LISt Processing Language. Initial ideas for Lisp were formulated in 1956-1958; some were implemented in FLPL (FORTRAN-based List Processing Language). The first Lisp implementation, for application to AI problems, took place 1958-1962 at MIT. There are many dialects of Lisp. Perhaps the most commonly used dialect is Common Lisp, which includes CLOS, the Common Lisp Object System. See http://www-formal.stanford.edu/jmc/history/lisp/lisp.html for some interesting details on the early history of Lisp. 1 Don't quote me! GNU Emacs Lisp Programming Slide 5 Copyright © 2001-2008 by William H.
    [Show full text]
  • Allegro CL User Guide
    Allegro CL User Guide Volume 1 (of 2) version 4.3 March, 1996 Copyright and other notices: This is revision 6 of this manual. This manual has Franz Inc. document number D-U-00-000-01-60320-1-6. Copyright 1985-1996 by Franz Inc. All rights reserved. No part of this pub- lication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means electronic, mechanical, by photocopying or recording, or otherwise, without the prior and explicit written permission of Franz incorpo- rated. Restricted rights legend: Use, duplication, and disclosure by the United States Government are subject to Restricted Rights for Commercial Software devel- oped at private expense as specified in DOD FAR 52.227-7013 (c) (1) (ii). Allegro CL and Allegro Composer are registered trademarks of Franz Inc. Allegro Common Windows, Allegro Presto, Allegro Runtime, and Allegro Matrix are trademarks of Franz inc. Unix is a trademark of AT&T. The Allegro CL software as provided may contain material copyright Xerox Corp. and the Open Systems Foundation. All such material is used and distrib- uted with permission. Other, uncopyrighted material originally developed at MIT and at CMU is also included. Appendix B is a reproduction of chapters 5 and 6 of The Art of the Metaobject Protocol by G. Kiczales, J. des Rivieres, and D. Bobrow. All this material is used with permission and we thank the authors and their publishers for letting us reproduce their material. Contents Volume 1 Preface 1 Introduction 1.1 The language 1-1 1.2 History 1-1 1.3 Format
    [Show full text]
  • A Python Implementation for Racket
    PyonR: A Python Implementation for Racket Pedro Alexandre Henriques Palma Ramos Thesis to obtain the Master of Science Degree in Information Systems and Computer Engineering Supervisor: António Paulo Teles de Menezes Correia Leitão Examination Committee Chairperson: Prof. Dr. José Manuel da Costa Alves Marques Supervisor: Prof. Dr. António Paulo Teles de Menezes Correia Leitão Member of the Committee: Prof. Dr. João Coelho Garcia October 2014 ii Agradecimentos Agradec¸o... Em primeiro lugar ao Prof. Antonio´ Leitao,˜ por me ter dado a oportunidade de participar no projecto Rosetta com esta tese de mestrado, por todos os sabios´ conselhos e pelos momentos de discussao˜ e elucidac¸ao˜ que se proporcionaram ao longo deste trabalho. Aos meus pais excepcionais e a` minha mana preferida, por me terem aturado e suportado ao longo destes quase 23 anos e sobretudo pelo incondicional apoio durante estes 5 anos de formac¸ao˜ superior. Ao pessoal do Grupo de Arquitectura e Computac¸ao˜ (Hugo Correia, Sara Proenc¸a, Francisco Freire, Pedro Alfaiate, Bruno Ferreira, Guilherme Ferreira, Inesˆ Caetano e Carmo Cardoso), por todas as sug- estoes˜ e pelo inestimavel´ feedback em artigos e apresentac¸oes.˜ Aos amigos em Tomar (Rodrigo Carrao,˜ Hugo Matos, Andre´ Marques e Rui Santos) e em Lisboa (Diogo da Silva, Nuno Silva, Pedro Engana, Kaguedes, Clara Paiva e Odemira), por terem estado pre- sentes, duma forma ou doutra, nos essenciais momentos de lazer. A` Fundac¸ao˜ para a Cienciaˆ e Tecnologia (FCT) e ao INESC-ID pelo financiamento e acolhimento atraves´ da atribuic¸ao˜ de uma bolsa de investigac¸ao˜ no ambitoˆ dos contratos Pest-OE/EEI/LA0021/2013 e PTDC/ATP-AQI/5224/2012.
    [Show full text]
  • An Extensible Constraint-Enabled Window Manager
    Scwm: An Extensible Constraint-Enabled Window Manager Greg J. Badros Jeffrey Nichols Alan Borning gjb,jwnichls,borning @cs.washington.edu f Dept. of Computer Scienceg and Engineering University of Washington, Box 352350 Seattle, WA 98195-2350, USA Abstract powerful, and satisfying. We desired a platform for researching advanced Using C to implement a highly-interactive applica- window layout paradigms including the use of con- tion also complicates extensibility and customiz- straints. Typical window management systems ability. To add a new feature, the user likely must are written entirely in C or C++, complicating write C code, recompile, relink, and restart the extensibility and programmability. Because no ex- application before changes are finally available for isting window manager was well-suited to our goal, testing and use. This development cycle is es- we developed the Scwm window manager. In pecially problematic for software such as a win- Scwm, only the core window-management primi- dow manager that generally is expected to run for tives are written in C while the rest of the pack- weeks at a time. Additionally, maintaining all the age is implemented in its Guile/Scheme exten- features that any user desires would result in ter- sion language. This architecture, first seen in rible code bloat. Emacs, enables programming substantial new fea- tures in Scheme and provides a solid infrastructure An increasingly popular solution to these prob- for constraint-based window layout research and lems is the use of a scripting language on top of other advanced capabilities such as voice recogni- a core system that defines new domain-specific tion.
    [Show full text]
  • Basic Lisp Techniques
    Basic Lisp Techniques David J. Cooper, Jr. February 14, 2011 ii 0Copyright c 2011, Franz Inc. and David J. Cooper, Jr. Foreword1 Computers, and the software applications that power them, permeate every facet of our daily lives. From groceries to airline reservations to dental appointments, our reliance on technology is all-encompassing. And, it’s not enough. Every day, our expectations of technology and software increase: • smart appliances that can be controlled via the internet • better search engines that generate information we actually want • voice-activated laptops • cars that know exactly where to go The list is endless. Unfortunately, there is not an endless supply of programmers and developers to satisfy our insatiable appetites for new features and gadgets. Every day, hundreds of magazine and on-line articles focus on the time and people resources needed to support future technological expectations. Further, the days of unlimited funding are over. Investors want to see results, fast. Common Lisp (CL) is one of the few languages and development options that can meet these challenges. Powerful, flexible, changeable on the fly — increasingly, CL is playing a leading role in areas with complex problem-solving demands. Engineers in the fields of bioinformatics, scheduling, data mining, document management, B2B, and E-commerce have all turned to CL to complete their applications on time and within budget. CL, however, no longer just appropriate for the most complex problems. Applications of modest complexity, but with demanding needs for fast development cycles and customization, are also ideal candidates for CL. Other languages have tried to mimic CL, with limited success.
    [Show full text]
  • Mlbibtex: Reporting the Experience∗
    MlBibTEX: Reporting the experience∗ Jean-Michel Hufflen LIFC (EA CNRS 4157) University of Franche-Comté 16, route de Gray 25030 BESANÇON CEDEX France hufflen (at) lifc dot univ-fcomte dot fr http://lifc.univ-fcomte.fr/~hufflen Abstract This article reports how the different steps of the MlBibTEX project were con- ducted until the first public release. We particularly focus on the problems raised by reimplementing a program (BibTEX) that came out in the 1980’s. Since that time, implementation techniques have evolved and new requirements have ap- peared, as well as new programs within TEX’s galaxy. Our choices are explained and discussed. Keywords TEX, LATEX, BibTEX, reimplementation, reverse engineering, im- plementation language, program update. Streszczenie Artykuł omawia realizację poszczególnych kroków przedsięwzięcia MlBibTEX, w czasie do przedstawienia pierwszej publicznej wersji. W szczególności skupiamy się na problemach powstałych przy reimplementacji programu (BibTEX), powsta- łego w latach 80 zeszłego wieku. Od tego czasu rozwinęły się techniki implemen- tacyjne, powstały nowe wymagania oraz nowe programy w świecie TEX-owym. Przedstawiamy i dyskutujemy dokonane wybory. Słowa kluczowe TEX, LATEX, BibTEX, reimplementacja, reverse engineering, język implementacji, aktualizacja programu. 0 Introduction aim to provide new programs, based on TEX & Co.’s ideas.2 A first representative example is the LAT X 3 In 2003, TEX’s 25th anniversary was celebrated at E 1 project [32], a second is N S [27]. the TUG conference, held in Hawaii [1]. LATEX T MlBibT X — for ‘MultiLingual BibT X’ — be- [28] and BibTEX [35] — the bibliography processor E E longs to the class of such projects. Let us recall usually associated with the LATEX word processor — are more recent, since they came out in the 1980’s, that this program aims to be a ‘better BibTEX’, especially regarding multilingual features.
    [Show full text]
  • Download Introduction to LISP and Symbol Manipulation, Sharam
    Introduction to LISP and symbol manipulation, Sharam Hekmatpour, Prentice Hall, 1988, 0134861922, 9780134861920, 303 pages. DOWNLOAD HERE Lisp , Paul M. Chirlian, 1986, Computers, 303 pages. The new UCI LISP manual , James Richard Meehan, Jun 1, 1979, Computers, 366 pages. Lisp machine manual , Richard Stallman, Daniel Weinreb, David Moon, 1984, Computers, 859 pages. LISP, the language of artificial intelligence , A. A. Berk, 1985, Computers, 160 pages. Common LISP A Gentle Introduction to Symbolic Computation, David S. Touretzky, 2013, Computers, 600 pages. Highly accessible treatment covers cons cell structures, evaluation rules, programs as data, recursive and applicable programming styles. Nearly 400 illustrations, answers to .... The T programming language a dialect of LISP, Stephen Slade, 1987, Computers, 425 pages. An Introduction to Programming in Emacs Lisp , Robert J. Chassell, Jan 1, 2004, , 289 pages. Introduction to ADA , Paul M. Chirlian, 1984, Computers, 291 pages. Has Been Written Easy Enough for the Beginner to Understand, Yet Comprehensive Enough for the Experienced Programmer. Includes Programs & Exercises. Syntactic extensions in the programming language LISP , Eugene Edmund Kohlbecker, 1986, Computers, 216 pages. The programmer's introduction to LISP , Ward Douglas Maurer, 1972, Computers, 112 pages. It's simply a WONDERFUL title on LISP. I got the opportunity to work on Lisp firstly during my Graduate, then during Doctoral Studies, both at Jawaharlal Nehru University, New Delhi, and finally while teaching graduate students of Computer Science at Punjabi University Patiala, Punjab, India, where I used this book as the main text book in the classroom. The book is very lucid, precise, and includes meaningful exercises and projects at the end of each chapter.
    [Show full text]
  • Reporting the Experience Jean-Michel Hufflen
    mlBibTeX: Reporting the Experience Jean-Michel Hufflen To cite this version: Jean-Michel Hufflen. mlBibTeX: Reporting the Experience. TUGB, 2007, pp.157–162. hal-00644467 HAL Id: hal-00644467 https://hal.archives-ouvertes.fr/hal-00644467 Submitted on 24 Nov 2011 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. ∗ MlBibTEX: Reporting the Experience Jean-Michel HUFFLEN LIFC (EA CNRS 4157) University of Franche-Comté 16, route de Gray 25030 BESANÇON CEDEX FRANCE [email protected] http://lifc.univ-fcomte.fr/~hufflen Abstract This article reports how the different steps of the MlBibTEX project were con- ducted until the first public release. We particularly focus on the problems raised by reimplementing a program (BibTEX) that came out in the 1980’s. Since this time, implementation techniques have evolved, new requirements have appeared, as well as new programs within TEX’s galaxy. Our choices are explained and discussed. Keywords TEX, LATEX, BibTEX, reimplementation, reverse engineering, im- plementation language, program update. Streszczenie Artykuł omawia realizację poszczególnych kroków przedsięwzięcia MlBibTEX, w czasie do przedstawienia pierwszej publicznej wersji. W szczególności skupiamy się na problemach powstałych przy reimplementacji programu (BibTEX), powsta- łego w latach 80 zeszłego wieku.
    [Show full text]
  • LISP a Programmable Programming Language
    LISP A Programmable Programming Language Christoph Müller 25.01.2017 Offenes Kolloquium für Informatik Agenda 1. Why Lisp? 2. The Basics of Lisp 3. Macros in Action 4. Tools and Platforms 5. Literature and more obscure Lisp dialects 6. Why it never (really) caught on 7. Bonus - A bit of History 1 Why Lisp? Timeless • When we talk about Lisp we talk about a language family • One of the oldest (∼ 1958) language families still in use today (only Fortran is older) • The Syntax is by its very nature timeless 2 Innovator • Garbage Collection • Homoiconicity (Code is Data) • Higher Order Functions • Dynamic Typing • Read Evaluate Print Loop (REPL) • Multiple Dispatch • And many more ... 3 Scheme - A Language for Teaching • Scheme was used as an introductory Language in famous Universities like MIT (6.001) • Extremely small language core • Great for learning to build your own abstractions 4 Picking a Language for this Talk Lets look at the most popular Lisp dialects on GitHub (provided by GitHut): GitHub Popuplarity Rank Language 20 Emacs Lisp 23 Clojure 40 Scheme 42 Common Lisp 48 Racket Clojure with its JVM heritage and Scheme with its focus on a small core will be used throughout this talk. 5 The Basics of Lisp The name giving lists • The basis of lisp is the s(ymbolic)-expression • Either a atom or a list • Atoms are either symbols or literals • Every element of a list is either an atom or another list • Elements are separated by whitespace and surrounded with parentheses • The first element of a (to be evaluated) list has to be what we will call a verb in this talk ;atoms x 12 ;lists (+ 1 2 3) (+ (* 2 3) 3) 6 What is a verb? • A verb is either a • A function • A macro • A special form • Special forms include if, fn, loop, recur etc.
    [Show full text]
  • Einführung in LISP
    Einführung in LISP Simon Lutz, Frank Preiswerk “Real Programmers don't write in LISP. Only idiots' programs contain more parenthesis than actual code.” “Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.” 04/19/06 Seminar 10 Programmiersprachen - Lisp/Scheme - Simon Lutz, Frank Preiswerk 1 Zeitlicher Überblick 1958: Lisp wurde von John McCarthy am MIT speziell für nicht-numerische Probleme designed und von Steve Russell auf einer IBM 704 Maschine implementiert. Der Name bedeutet “List Processing Language”. 1968: Erster Lisp Compiler geschrieben in Lisp von Tim Hart und Mike Levin. 1968-70: Implementation von SHRDLU mittels Lisp, berühmtes AI-System. 1970er Jahre: Performanz von bestehenden Lisp-Systemen wird zum Thema, es entstehen optimierte Lisp-Maschinen. Heute wieder verschwunden. 1980er – 1990er Jahre: Bemühungen für eine Vereinheitlichung der vielen bestehenden Lisp-Dialekte: Common Lisp entsteht. 1994: ANSI veröffentlicht Common Lisp Standard. Dies zu einem Zeitpunkt, als der Weltmarkt für Lisp viel kleiner war als in den früheren Zeiten. 04/19/06 Seminar 10 Programmiersprachen - Lisp/Scheme - Simon Lutz, Frank Preiswerk 2 Lisp heute Nach einem Rückgang in den 90er Jahren ist das Interesse seit 2000 wieder gestiegen, massgeblich im Rahmen von Open Source Implementationen von Common Lisp. 2004: Peter Seibel’s “Practical Common Lisp” ist für kurze Zeit an zweiter Stelle von Amazon’s populärsten Programmierbüchern. April 2006: Tiobe Software rankt Lisp auf Platz 14 der populärsten Programmiersprachen. Neue “Lisper” beschreiben die Sprache gerne als “eye-opening experience” und behaupten, in Lisp deutlich produktiver zu sein als in anderen Sprachen.
    [Show full text]