Programming in Lua (First Edition) This Is an Online Version of the First Edition of the Book

Total Page:16

File Type:pdf, Size:1020Kb

Programming in Lua (First Edition) This Is an Online Version of the First Edition of the Book Programming in Lua (first edition) This is an online version of the first edition of the book Programming in Lua by Roberto Ierusalimschy Lua.org, December 2003 ISBN 85-903798-1-7 The book is a detailed and authoritative introduction to all aspects of Lua programming, by Lua's chief architect. The first edition was aimed at Lua 5.0 and remains largely relevant. If you find this online version useful, please consider buying a copy of the second edition, which updates the text to Lua 5.1 and brings substantial new material. This helps to support the Lua project. For the official definition of the Lua language, see the reference manual. Copyright © 2003-2004 Roberto Ierusalimschy. All rights reserved. This online book is for personal use only. It cannot be copied to other web sites or further distributed in any form. Contents Part I · The Language • 1 - Getting Started • 1.1 - Chunks • 1.2 - Global Variables • 1.3 - Some Lexical Conventions • 1.4 - The Stand-Alone Interpreter • 2 - Types and Values • 2.1 - Nil • 2.2 - Booleans • 2.3 - Numbers • 2.4 - Strings • 2.5 - Tables • 2.6 - Functions • 2.7 - Userdata and Threads • 3 - Expressions • 3.1 - Arithmetic Operators • 3.2 - Relational Operators • 3.3 - Logical Operators • 3.4 - Concatenation • 3.5 - Precedence • 3.6 - Table Constructors • 4 - Statements • 4.1 - Assignment • 4.2 - Local Variables and Blocks • 4.3 - Control Structures • 4.3.1 - if then else • 4.3.2 - while • 4.3.3 - repeat • 4.3.4 - Numeric for • 4.3.5 - Generic for • 4.4 - break and return • 5 - Functions • 5.1 - Multiple Results • 5.2 - Variable Number of Arguments • 5.3 - Named Arguments • 6 - More about Functions • 6.1 - Closures • 6.2 - Non-Global Functions • 6.3 - Proper Tail Calls • 7 - Iterators and the Generic for • 7.1 - Iterators and Closures • 7.2 - The Semantics of the Generic for • 7.3 - Stateless Iterators • 7.4 - Iterators with Complex State • 7.5 - True Iterators • 8 - Compilation, Execution, and Errors • 8.1 - The require Function • 8.2 - C Packages • 8.3 - Errors • 8.4 - Error Handling and Exceptions • 8.5 - Error Messages and Tracebacks • 9 - Coroutines • 9.1 - Coroutine Basics • 9.2 - Pipes and Filters • 9.3 - Coroutines as Iterators • 9.4 - Non-Preemptive Multithreading • 10 - Complete Examples • 10.1 - Data Description • 10.2 - Markov Chain Algorithm • • Part II · Tables and Objects • 11 - Data Structures • 11.1 - Arrays • 11.2 - Matrices and Multi-Dimensional Arrays • 11.3 - Linked Lists • 11.4 - Queues and Double Queues • 11.5 - Sets and Bags • 11.6 - String Buffers • 12 - Data Files and Persistence • 12.1 - Serialization • 12.1.1 - Saving Tables without Cycles • 12.1.2 - Saving Tables with Cycles • 13 - Metatables and Metamethods • 13.1 - Arithmetic Metamethods • 13.2 - Relational Metamethods • 13.3 - Library-Defined Metamethods • 13.4 - Table-Access Metamethods • 13.4.1 - The __index Metamethod • 13.4.2 - The __newindex Metamethod • 13.4.3 - Tables with Default Values • 13.4.4 - Tracking Table Accesses • 13.4.5 - Read-Only Tables • 14 - The Environment • 14.1 - Accessing Global Variables with Dynamic Names • 14.2 - Declaring Global Variables • 14.3 - Non-Global Environments • 15 - Packages • 15.1 - The Basic Approach • 15.2 - Privacy • 15.3 - Packages and Files • 15.4 - Using the Global Table • 15.5 - Other Facilities • 16 - Object-Oriented Programming • 16.1 - Classes • 16.2 - Inheritance • 16.3 - Multiple Inheritance • 16.4 - Privacy • 16.5 - The Single-Method Approach • 17 - Weak Tables • 17.1 - Memoize Functions • 17.2 - Object Attributes • 17.3 - Revisiting Tables with Default Values • Part III · The Standard Libraries • 18 - The Mathematical Library • 19 - The Table Library • 19.1 - Array Size • 19.2 - Insert and Remove • 19.3 - Sort • 20 - The String Library • 20.1 - Pattern-Matching Functions • 20.2 - Patterns • 20.3 - Captures • 20.4 - Tricks of the Trade • 21 - The I/O Library • 21.1 - The Simple I/O Model • 21.2 - The Complete I/O Model • 21.2.1 - A Small Performance Trick • 21.2.2 - Binary Files • 21.3 - Other Operations on Files • 22 - The Operating System Library • 22.1 - Date and Time • 22.2 - Other System Calls • 23 - The Debug Library • 23.1 - Introspective Facilities • 23.1.1 - Accessing Local Variables • 23.1.2 - Accessing Upvalues • 23.2 - Hooks • 23.3 - Profiles • Part IV · The C API • 24 - An Overview of the C API • 24.1 - A First Example • 24.2 - The Stack • 24.2.1 - Pushing Elements • 24.2.2 - Querying Elements • 24.2.3 - Other Stack Operations • 24.3 - Error Handling with the C API • 24.3.1 - Error Handling in Application Code • 24.3.2 - Error Handling in Library Code • 25 - Extending your Application • 25.1 - Table Manipulation • 25.2 - Calling Lua Functions • 25.3 - A Generic Call Function • 26 - Calling C from Lua • 26.1 - C Functions • 26.2 - C Libraries • 27 - Techniques for Writing C Functions • 27.1 - Array Manipulation • 27.2 - String Manipulation • 27.3 - Storing State in C Functions • 27.3.1 - The Registry • 27.3.2 - References • 27.3.3 - Upvalues • 28 - User-Defined Types in C • 28.1 - Userdata • 28.2 - Metatables • 28.3 - Object-Oriented Access • 28.4 - Array Access • 28.5 - Light Userdata • 29 - Managing Resources • 29.1 - A Directory Iterator • 29.2 - An XML Parser 1 - Getting Started To keep with the tradition, our first program in Lua just prints "Hello World": print("Hello World") If you are using the stand-alone Lua interpreter, all you have to do to run your first program is to call the interpreter (usually named lua) with the name of the text file that contains your program. For instance, if you write the above program in a file hello.lua, the following command should run it: prompt> lua hello.lua As a slightly more complex example, the following program defines a function to compute the factorial of a given number, asks the user for a number, and prints its factorial: -- defines a factorial function function fact (n) if n == 0 then return 1 else return n * fact(n-1) end end print("enter a number:") a = io.read("*number") -- read a number print(fact(a)) If you are using Lua embedded in an application, such as CGILua or IUPLua, you may need to refer to the application manual (or to a "local guru") to learn how to run your programs. Nevertheless, Lua is still the same language; most things that we will see here are valid regardless of how you are using Lua. For a start, we recommend that you use the stand-alone interpreter (that is, the lua executable) to run your first examples and experiments. 1 - Getting Started To keep with the tradition, our first program in Lua just prints "Hello World": print("Hello World") If you are using the stand-alone Lua interpreter, all you have to do to run your first program is to call the interpreter (usually named lua) with the name of the text file that contains your program. For instance, if you write the above program in a file hello.lua, the following command should run it: prompt> lua hello.lua As a slightly more complex example, the following program defines a function to compute the factorial of a given number, asks the user for a number, and prints its factorial: -- defines a factorial function function fact (n) if n == 0 then return 1 else return n * fact(n-1) end end print("enter a number:") a = io.read("*number") -- read a number print(fact(a)) If you are using Lua embedded in an application, such as CGILua or IUPLua, you may need to refer to the application manual (or to a "local guru") to learn how to run your programs. Nevertheless, Lua is still the same language; most things that we will see here are valid regardless of how you are using Lua. For a start, we recommend that you use the stand-alone interpreter (that is, the lua executable) to run your first examples and experiments. 1.1 - Chunks Each piece of code that Lua executes, such as a file or a single line in interactive mode, is a chunk. More specifically, a chunk is simply a sequence of statements. A semicolon may optionally follow any statement. Usually, I use semicolons only to separate two or more statements written in the same line, but this is just a convention. Line breaks play no role in Lua's syntax; for instance, the following four chunks are all valid and equivalent: a = 1 b = a*2 a = 1; b = a*2; a = 1 ; b = a*2 a = 1 b = a*2 -- ugly, but valid A chunk may be as simple as a single statement, such as in the "hello world" example, or it may be composed of a mix of statements and function definitions (which are assignments actually, as we will see later), such as the factorial example. A chunk may be as large as you wish. Because Lua is used also as a data-description language, chunks with several megabytes are not uncommon. The Lua interpreter has no problems at all with large sizes. Instead of writing your program to a file, you may run the stand-alone interpreter in interactive mode. If you call Lua without any arguments, you will get its prompt: Lua 5.0 Copyright (C) 1994-2003 Tecgraf, PUC-Rio > Thereafter, each command that you type (such as print "Hello World") executes immediately after you press <enter>. To exit the interactive mode and the interpreter, just type end-of-file (ctrl-D in Unix, ctrl-Z in DOS/Windows), or call the exit function, from the Operating System library (you have to type os.exit()<enter>).
Recommended publications
  • Rocket Universe 11 Structural Changes
    Rocket UniVerse 11 Structural Changes What you need to know before you install or upgrade to UniVerse 11 Rocket U2 Technical Support Supplemental Information April 2014 UNV-112-REP-OG-1 Notices Edition Publication date: April 2014 Book number: UNV-112-REP-OG-1 Product version: Rocket UniVerse V11.2 Copyright © Rocket Software, Inc. or its affiliate 1985-2014. All Rights Reserved. Trademarks Rocket is a registered trademark of Rocket Software, Inc. For a list of Rocket registered trademarks go to: www.rocketsoftware.com/about/legal. All other products or services mentioned in this document may be covered by the trademarks, service marks, or product names of their respective owners. Examples This information might contain examples of data and reports. The examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to the names and addresses used by an actual business enterprise is entirely coincidental. License agreement This software and the associated documentation are proprietary and confidential to Rocket Software, Inc. or its affiliates, are furnished under license, and may be used and copied only in accordance with the terms of such license. Note: This product may contain encryption technology. Many countries prohibit or restrict the use, import, or export of encryption technologies, and current use, import, and export regulations should be followed when exporting this product. Contact information Website: www.rocketsoftware.com Rocket Software, Inc. Headquarters 77 4th Avenue, Suite 100 Waltham, MA 02451-1468 USA Tel: +1 781 577 4321 Fax: +1 617 630 7100 2 Contacting Global Technical Support If you have current support and maintenance agreements with Rocket Software, you can access the Rocket Customer Portal to report and track a problem, to submit an enhancement request or question, or to find answers in the U2 Knowledgebase.
    [Show full text]
  • Programming Languages
    Programming Languages Recitation Summer 2014 Recitation Leader • Joanna Gilberti • Email: [email protected] • Office: WWH, Room 328 • Web site: http://cims.nyu.edu/~jlg204/courses/PL/index.html Homework Submission Guidelines • Submit all homework to me via email (at [email protected] only) on the due date. • Email subject: “PL– homework #” (EXAMPLE: “PL – Homework 1”) • Use file naming convention on all attachments: “firstname_lastname_hw_#” (example: "joanna_gilberti_hw_1") • In the case multiple files are being submitted, package all files into a ZIP file, and name the ZIP file using the naming convention above. What’s Covered in Recitation • Homework Solutions • Questions on the homeworks • For additional questions on assignments, it is best to contact me via email. • I will hold office hours (time will be posted on the recitation Web site) • Run sample programs that demonstrate concepts covered in class Iterative Languages Scoping • Sample Languages • C: static-scoping • Perl: static and dynamic-scoping (use to be only dynamic scoping) • Both gcc (to run C programs), and perl (to run Perl programs) are installed on the cims servers • Must compile the C program with gcc, and then run the generated executable • Must include the path to the perl executable in the perl script Basic Scope Concepts in C • block scope (nested scope) • run scope_levels.c (sl) • ** block scope: set of statements enclosed in braces {}, and variables declared within a block has block scope and is active and accessible from its declaration to the end of the block
    [Show full text]
  • Armadillo C++ Library
    Armadillo: a template-based C++ library for linear algebra Conrad Sanderson and Ryan Curtin Abstract The C++ language is often used for implementing functionality that is performance and/or resource sensitive. While the standard C++ library provides many useful algorithms (such as sorting), in its current form it does not provide direct handling of linear algebra (matrix maths). Armadillo is an open source linear algebra library for the C++ language, aiming towards a good balance between speed and ease of use. Its high-level application programming interface (function syntax) is deliberately similar to the widely used Matlab and Octave languages [4], so that mathematical operations can be expressed in a familiar and natural manner. The library is useful for algorithm development directly in C++, or relatively quick conversion of research code into production environments. Armadillo provides efficient objects for vectors, matrices and cubes (third order tensors), as well as over 200 associated functions for manipulating data stored in the objects. Integer, floating point and complex numbers are supported, as well as dense and sparse storage formats. Various matrix factorisations are provided through integration with LAPACK [3], or one of its high performance drop-in replacements such as Intel MKL [6] or OpenBLAS [9]. It is also possible to use Armadillo in conjunction with NVBLAS to obtain GPU-accelerated matrix multiplication [7]. Armadillo is used as a base for other open source projects, such as MLPACK, a C++ library for machine learning and pattern recognition [2], and RcppArmadillo, a bridge between the R language and C++ in order to speed up computations [5].
    [Show full text]
  • Chapter 5 Names, Bindings, and Scopes
    Chapter 5 Names, Bindings, and Scopes 5.1 Introduction 198 5.2 Names 199 5.3 Variables 200 5.4 The Concept of Binding 203 5.5 Scope 211 5.6 Scope and Lifetime 222 5.7 Referencing Environments 223 5.8 Named Constants 224 Summary • Review Questions • Problem Set • Programming Exercises 227 CMPS401 Class Notes (Chap05) Page 1 / 20 Dr. Kuo-pao Yang Chapter 5 Names, Bindings, and Scopes 5.1 Introduction 198 Imperative languages are abstractions of von Neumann architecture – Memory: stores both instructions and data – Processor: provides operations for modifying the contents of memory Variables are characterized by a collection of properties or attributes – The most important of which is type, a fundamental concept in programming languages – To design a type, must consider scope, lifetime, type checking, initialization, and type compatibility 5.2 Names 199 5.2.1 Design issues The following are the primary design issues for names: – Maximum length? – Are names case sensitive? – Are special words reserved words or keywords? 5.2.2 Name Forms A name is a string of characters used to identify some entity in a program. Length – If too short, they cannot be connotative – Language examples: . FORTRAN I: maximum 6 . COBOL: maximum 30 . C99: no limit but only the first 63 are significant; also, external names are limited to a maximum of 31 . C# and Java: no limit, and all characters are significant . C++: no limit, but implementers often impose a length limitation because they do not want the symbol table in which identifiers are stored during compilation to be too large and also to simplify the maintenance of that table.
    [Show full text]
  • Introduction to Programming in Lisp
    Introduction to Programming in Lisp Supplementary handout for 4th Year AI lectures · D W Murray · Hilary 1991 1 Background There are two widely used languages for AI, viz. Lisp and Prolog. The latter is the language for Logic Programming, but much of the remainder of the work is programmed in Lisp. Lisp is the general language for AI because it allows us to manipulate symbols and ideas in a commonsense manner. Lisp is an acronym for List Processing, a reference to the basic syntax of the language and aim of the language. The earliest list processing language was in fact IPL developed in the mid 1950’s by Simon, Newell and Shaw. Lisp itself was conceived by John McCarthy and students in the late 1950’s for use in the newly-named field of artificial intelligence. It caught on quickly in MIT’s AI Project, was implemented on the IBM 704 and by 1962 to spread through other AI groups. AI is still the largest application area for the language, but the removal of many of the flaws of early versions of the language have resulted in its gaining somewhat wider acceptance. One snag with Lisp is that although it started out as a very pure language based on mathematic logic, practical pressures mean that it has grown. There were many dialects which threaten the unity of the language, but recently there was a concerted effort to develop a more standard Lisp, viz. Common Lisp. Other Lisps you may hear of are FranzLisp, MacLisp, InterLisp, Cambridge Lisp, Le Lisp, ... Some good things about Lisp are: • Lisp is an early example of an interpreted language (though it can be compiled).
    [Show full text]
  • Ercatons and Organic Programming: Say Good-Bye to Planned Economy
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by Dagstuhl Research Online Publication Server Ercatons and Organic Programming: Say Good-Bye to Planned Economy Oliver Imbusch, Falk Langhammer and Guido von Walter Living Pages Research GmbH Kolosseumstrasse 1a, 80469 Munich, Germany {flabes|falk|guido}@livis.com ABSTRACT 1. Motivation Organic programming (OP) is our proposed and already We are going to present an alternative way to develop soft- emerging programming model which overcomes some of ware. We followed this idea starting from some general the limitations of current practice in software development observations all the way down to a reference implementa- in general and of object-oriented programming (OOP) in tion which was then used in projects of sufficient size. This particular. Ercatons provide an implementation of the makes us trust into the initial idea to the point that we may model. In some respects, OP is less than a (new) program- now be obsessed by it. Let us start by sharing some of the ming language, in others, it is more. An “ercato machine” general observations. implements the ideas discussed and has been used to vali- We start with this trivial anecdote. date the concepts described here. “One morning, we noticed some workers tile our office's Organic programming is centered around the concept of a backyard. The day before, piles of square tiles had been true “Thing”. A thing in an executing software system is delivered and the workers now seemed to make good prog- bound to behave the way an autonomous object does in our ress covering the backyard's middle section.
    [Show full text]
  • Scala Tutorial
    Scala Tutorial SCALA TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Scala Tutorial Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way. Scala has been created by Martin Odersky and he released the first version in 2003. Scala smoothly integrates features of object-oriented and functional languages. This tutorial gives a great understanding on Scala. Audience This tutorial has been prepared for the beginners to help them understand programming Language Scala in simple and easy steps. After completing this tutorial, you will find yourself at a moderate level of expertise in using Scala from where you can take yourself to next levels. Prerequisites Scala Programming is based on Java, so if you are aware of Java syntax, then it's pretty easy to learn Scala. Further if you do not have expertise in Java but you know any other programming language like C, C++ or Python, then it will also help in grasping Scala concepts very quickly. Copyright & Disclaimer Notice All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the accuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site or this tutorial content contains some errors, please contact us at [email protected] TUTORIALS POINT Simply Easy Learning Table of Content Scala Tutorial ..........................................................................
    [Show full text]
  • Scope in Fortran 90
    Scope in Fortran 90 The scope of objects (variables, named constants, subprograms) within a program is the portion of the program in which the object is visible (can be use and, if it is a variable, modified). It is important to understand the scope of objects not only so that we know where to define an object we wish to use, but also what portion of a program unit is effected when, for example, a variable is changed, and, what errors might occur when using identifiers declared in other program sections. Objects declared in a program unit (a main program section, module, or external subprogram) are visible throughout that program unit, including any internal subprograms it hosts. Such objects are said to be global. Objects are not visible between program units. This is illustrated in Figure 1. Figure 1: The figure shows three program units. Main program unit Main is a host to the internal function F1. The module program unit Mod is a host to internal function F2. The external subroutine Sub hosts internal function F3. Objects declared inside a program unit are global; they are visible anywhere in the program unit including in any internal subprograms that it hosts. Objects in one program unit are not visible in another program unit, for example variable X and function F3 are not visible to the module program unit Mod. Objects in the module Mod can be imported to the main program section via the USE statement, see later in this section. Data declared in an internal subprogram is only visible to that subprogram; i.e.
    [Show full text]
  • Cmsc 132: Object-Oriented Programming Ii
    © Department of Computer Science UMD CMSC 132: OBJECT-ORIENTED PROGRAMMING II Iterator, Marker, Observer Design Patterns Department of Computer Science University of Maryland, College Park © Department of Computer Science UMD Design Patterns • Descriptions of reusable solutions to common software design problems (e.g, Iterator pattern) • Captures the experience of experts • Goals • Solve common programming challenges • Improve reliability of solution • Aid rapid software development • Useful for real-world applications • Design patterns are like recipes – generic solutions to expected situations • Design patterns are language independent • Recognizing when and where to use design patterns requires familiarity & experience • Design pattern libraries serve as a glossary of idioms for understanding common, but complex solutions • Design patterns are used throughout the Java Class Libraries © Department of Computer Science UMD Iterator Pattern • Definition • Move through collection of objects without knowing its internal representation • Where to use & benefits • Use a standard interface to represent data objects • Uses standard iterator built in each standard collection, like List • Need to distinguish variations in the traversal of an aggregate • Example • Iterator for collection • Original • Examine elements of collection directly • Using pattern • Collection provides Iterator class for examining elements in collection © Department of Computer Science UMD Iterator Example public interface Iterator<V> { bool hasNext(); V next(); void remove();
    [Show full text]
  • Iterators in C++ C 2016 All Rights Reserved
    Software Design Lecture Notes Prof. Stewart Weiss Iterators in C++ c 2016 All rights reserved. Iterators in C++ 1 Introduction When a program needs to visit all of the elements of a vector named myvec starting with the rst and ending with the last, you could use an iterative loop such as the following: for ( int i = 0; i < myvec.size(); i++ ) // the visit, i.e., do something with myvec[i] This code works and is a perfectly ne solution. This same type of iterative loop can visit each character in a C++ string. But what if you need code that visits all elements of a C++ list object? Is there a way to use an iterative loop to do this? To be clear, an iterative loop is one that has the form for var = start value; var compared to end value; update var; {do something with node at specic index} In other words, an iterative loop is a counting loop, as opposed to one that tests an arbitrary condition, like a while loop. The short answer to the question is that, in C++, without iterators, you cannot do this. Iterators make it possible to iterate through arbitrary containers. This set of notes answers the question, What is an iterator, and how do you use it? Iterators are a generalization of pointers in C++ and have similar semantics. They allow a program to navigate through dierent types of containers in a uniform manner. Just as pointers can be used to traverse a linked list or a binary tree, and subscripts can be used to traverse the elements of a vector, iterators can be used to sequence through the elements of any standard C++ container class.
    [Show full text]
  • Programming Language Concepts/Binding and Scope
    Programming Language Concepts/Binding and Scope Programming Language Concepts/Binding and Scope Onur Tolga S¸ehito˘glu Bilgisayar M¨uhendisli˘gi 11 Mart 2008 Programming Language Concepts/Binding and Scope Outline 1 Binding 6 Declarations 2 Environment Definitions and Declarations 3 Block Structure Sequential Declarations Monolithic block structure Collateral Declarations Flat block structure Recursive declarations Nested block structure Recursive Collateral Declarations 4 Hiding Block Expressions 5 Static vs Dynamic Scope/Binding Block Commands Static binding Block Declarations Dynamic binding 7 Summary Programming Language Concepts/Binding and Scope Binding Binding Most important feature of high level languages: programmers able to give names to program entities (variable, constant, function, type, ...). These names are called identifiers. Programming Language Concepts/Binding and Scope Binding Binding Most important feature of high level languages: programmers able to give names to program entities (variable, constant, function, type, ...). These names are called identifiers. definition of an identifier ⇆ used position of an identifier. Formally: binding occurrence ⇆ applied occurrence. Programming Language Concepts/Binding and Scope Binding Binding Most important feature of high level languages: programmers able to give names to program entities (variable, constant, function, type, ...). These names are called identifiers. definition of an identifier ⇆ used position of an identifier. Formally: binding occurrence ⇆ applied occurrence. Identifiers are declared once, used n times. Programming Language Concepts/Binding and Scope Binding Binding Most important feature of high level languages: programmers able to give names to program entities (variable, constant, function, type, ...). These names are called identifiers. definition of an identifier ⇆ used position of an identifier. Formally: binding occurrence ⇆ applied occurrence. Identifiers are declared once, used n times.
    [Show full text]
  • Generic Programming
    Generic Programming July 21, 1998 A Dagstuhl Seminar on the topic of Generic Programming was held April 27– May 1, 1998, with forty seven participants from ten countries. During the meeting there were thirty seven lectures, a panel session, and several problem sessions. The outcomes of the meeting include • A collection of abstracts of the lectures, made publicly available via this booklet and a web site at http://www-ca.informatik.uni-tuebingen.de/dagstuhl/gpdag.html. • Plans for a proceedings volume of papers submitted after the seminar that present (possibly extended) discussions of the topics covered in the lectures, problem sessions, and the panel session. • A list of generic programming projects and open problems, which will be maintained publicly on the World Wide Web at http://www-ca.informatik.uni-tuebingen.de/people/musser/gp/pop/index.html http://www.cs.rpi.edu/˜musser/gp/pop/index.html. 1 Contents 1 Motivation 3 2 Standards Panel 4 3 Lectures 4 3.1 Foundations and Methodology Comparisons ........ 4 Fundamentals of Generic Programming.................. 4 Jim Dehnert and Alex Stepanov Automatic Program Specialization by Partial Evaluation........ 4 Robert Gl¨uck Evaluating Generic Programming in Practice............... 6 Mehdi Jazayeri Polytypic Programming........................... 6 Johan Jeuring Recasting Algorithms As Objects: AnAlternativetoIterators . 7 Murali Sitaraman Using Genericity to Improve OO Designs................. 8 Karsten Weihe Inheritance, Genericity, and Class Hierarchies.............. 8 Wolf Zimmermann 3.2 Programming Methodology ................... 9 Hierarchical Iterators and Algorithms................... 9 Matt Austern Generic Programming in C++: Matrix Case Study........... 9 Krzysztof Czarnecki Generative Programming: Beyond Generic Programming........ 10 Ulrich Eisenecker Generic Programming Using Adaptive and Aspect-Oriented Programming .
    [Show full text]