2010 Workshop on Scheme and Functional Programming
Total Page:16
File Type:pdf, Size:1020Kb
2010 Workshop on Scheme and Functional Programming Montreal,´ Quebec,´ Canada Saturday and Sunday August 21-22, 2010 2 Preface This report contains the papers presented at the Eleventh Workshop on Scheme and Functional Programming, held on Saturday and Sunday, August 21 and 22, 2010 at the Universite´ de Montreal.´ Eight papers were submitted in response to the call for papers. Each paper was evaluated by three reviewers. After due deliberation, the program committee decided to accept all papers. This year the program includes lightning talks which we hope will help the exchange of new ideas and developments between the participants. We thank Olin Shivers and Robby Findler who have graciously accepted our invitation to present their work. The Scheme Language committees will report on their progress towards the next Scheme standard. The workshop has been extended from its traditional one day format to a day and a half to accommodate all of the presentations. Finally we would like to thank Robby Findler for helping out with the formatting of the proceedings, and Virginie Allard-Cameus,´ Marie-Josee´ Boulay, and Line Pariseau for taking care of the catering and other local arrangements. Marc Feeley Universite´ de Montreal´ Organizer and Program Chair Program Committee Alan Bawden (independent consultant) Felix S. Klock II (Adobe Systems Incorporated) Olivier Danvy (Aarhus University) Jay McCarthy (Brigham Young University) Christopher Dutchyn (University of Saskatchewan) Scott McKay (ITA software) Marc Feeley (Universite´ de Montreal)´ Steering Committee William D. Clinger (Northeastern University) Christian Queinnec (Universite´ Pierre et Marie Curie) Marc Feeley (Universite´ de Montreal)´ Manuel Serrano (INRIA Sophia Antipolis) Robby Findler (Northwestern University) Olin Shivers (Northeastern University) Dan Friedman (Indiana University) Mitchell Wand (Northeastern University) 3 4 Schedule & Table of Contents Saturday, August 21 8:15 On-site registration and breakfast 9:00 Invited Talk: Eager parsing and user interaction with call/cc ......................... 7 Olin Shivers (Northeastern University) 10:00 Break 10:30 Functional Data Structures for Typed Racket ......................................... 8 Hari Prashanth K R and Sam Tobin-Hochstadt (Northeastern University) 11:00 Implementing User-level Value-weak Hashtables ................................... 15 Aaron W. Hsu (Indiana University) 11:30 Break 12:00 Pushdown Control-Flow Analysis of Higher-Order Programs ....................... 24 Christopher Earl (University of Utah), Matthew Might (University of Utah), and David Van Horn (Northeastern University) 12:30 Lightning talks Speakers to be announced at the workshop 12:45 Lunch 14:00 Measuring the Effectiveness of Error Messages Designed for Novice . 36 Programmers Guillaume Marceau (Worcester Polytechnic Institute), Kathi Fisler (Worcester Polytechnic Institute), and Shriram Krishnamurthi (Brown University) 14:30 JazzScheme: Evolution of a Lisp-Based Development System ....................... 50 Guillaume Cartier and Louis-Julien Guillemette (Auphelia Technologies Inc.) 15:00 Break 15:30 The Design of a Functional Image Library .......................................... 60 Ian Barland (Radford University), Robert Bruce Findler (Northwestern University), and Matthew Flatt (University of Utah) 16:00 Enabling cross-library optimization and compile-time error checking . 66 in the presence of procedural macros Andrew W. Keep and R. Kent Dybvig (Indiana University) 5 16:30 Break 17:00 Guiding Requirements for the Ongoing Scheme Standardization Process . 77 Mario Latendresse (SRI International) 17:20 Lightning talks Speakers to be announced at the workshop Sunday, August 22 8:15 Breakfast 9:00 Invited Talk: Contracts in Racket .................................................... 81 Robert Bruce Findler (Northwestern University) 10:00 Break 10:30 Report by the Scheme Language Steering Committee Report by the Scheme Language Working Groups 12:00 Closing 6 Invited Talk: Eager parsing and user interaction with call/cc Olin Shivers Northeastern University Abstract Many s-expressions have the pleasant property of being syntactically self-terminating: we know when we come to the right parenthesis at the end of a list that the list is complete. Old (but advanced) Lisp systems such as Maclisp and the Lisp Machine exploited this fact by interleaving the parser and the interactive “rubout” handler: a call to the reader completes as soon as the parser has consumed a complete s-expression without the user needing to input a following separator character. Yet the user is also able to correct erroneous, incomplete input by “backing up” with the delete key and re-entering corrected text. Implementing such an input facility turns out to be a task for which Scheme has just the right tools: call/cc and other higher-order control operators. I will show how to use these operators to implement a reader that is eager, yet interactively permits correction. Although the parsing and error-correction functionality is interleaved, the code is not. The implementation is quite modular: the reader is a standard, off-the-shelf recursive-descent parser, written with no concern for error correction; the error-correction code works with any parser that needs no more than one character of lookahead. The talk will show the development of real code, giving a demonstration of how Scheme’s sophisticated control operators are put to work in a real systems-programming context. 7 Functional Data Structures for Typed Racket Hari Prashanth K R Sam Tobin-Hochstadt Northeastern University Northeastern University [email protected] [email protected] Abstract supports untagged rather than disjoint unions. Thus, most data Scheme provides excellent language support for programming in structures presented here are implemented as unions of several dis- a functional style, but little in the way of library support. In this tinct structure types. paper, we present a comprehensive library of functional data struc- tures, drawing from several sources. We have implemented the li- 1.2 Interoperation with External Code brary in Typed Racket, a typed variant of Racket, allowing us to Most Scheme programs are neither purely functional nor typed. maintain the type invariants of the original definitions. That does not prevent them from benefiting from the data struc- tures presented in this paper, however. Typed Racket automatically 1. Functional Data Structures for a Functional supports interoperation between typed and untyped code, allowing any program to use the data structures presented here, regardless of Language whether it is typed. Typed Racket does however enforce its type in- Functional programming requires more than just lambda; library variants via software contracts, which can reduce the performance support for programming in a functional style is also required. of the structures. In particular, efficient and persistent functional data structures are Additionally, using these data structures in no way requires needed in almost every program. programming in a purely functional style. An mostly-functional Scheme does provide one supremely valuable functional data Scheme program that does not mutate a list can replace that list structure—the linked list. This is sufficient to support many forms with a VList without any problem. Using functional data structures of functional programming (Shivers 1999) (although lists are sadly often adds persistence and performance without subtracting func- mutable in most Schemes), but not nearly sufficient. To truly sup- tionality. port efficient programming in a functional style, additional data structures are needed. Fortunately, the last 15 years have seen the development of 2. An Introduction to Functional Data Structures many efficient and useful functional data structures, in particular Purely functional data structures, like all data structures, come in by Okasaki (1998) and Bagwell (2002; 2000). These data structures many varieties. For this work, we have selected a variety that pro- have seen wide use in languages such as Haskell and Clojure, but vide different APIs and performance characteristics. They include have rarely been implemented in Scheme. several variants of queues, double-ended queues (or deques), pri- In this paper, we present a comprehensive library of efficient ority queues (or heaps), lists, hash lists, tries, red-black trees, and functional data structures, implemented in Typed Racket (Tobin- streams. All of the implemented data structures are polymorphic in Hochstadt and Felleisen 2008), a recently-developed typed dialect their element type. of Racket (formerly PLT Scheme). The remainder of the paper is The following subsections describe each of these data struc- organized as follows. We first present an overview of Typed Racket, tures, many with a number of different implementations with dis- and describe how typed functional datastructures can interoperate tinct performance characteristics. Each subsection introduces the with untyped, imperative code. Section 2 describes the data struc- data structure, specifies its API, provides examples, and then dis- tures, with their API and their performance characteristics. In sec- cusses each implementation variant and their performance charac- tion 3, we present benchmarks demonstrating that our implemena- teristics. tions are viable for use in real code. We then detail the experience of using Typed Racket for this project, both positive and negative. 2.1 Queues Finally, we discuss