{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Inside PLT MzScheme

How to Design Programs: An Introduction to Programming and Computing

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

View Full Document Right Arrow Icon
Inside PLT MzScheme Matthew Flatt ([email protected]) 372 Released December 2007
Background image of page 1

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

View Full Document Right Arrow Icon
Copyright notice Copyright c 1995-2007 Matthew Flatt Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Library General Public License, Version 2 published by the Free Software Foundation. A copy of the license is included in the appendix entitled “License.” libscheme: Copyright c 1994 Brent Benson. All rights reserved. Conservative garbage collector: Copyright c 1988, 1989 Hans-J. Boehm, Alan J. Demers. Copyright c 1991-1996 by Xerox Corporation. Copyright c 1996-1999 by Silicon Graphics. Copyright c 1999-2001 by Hewlett Packard Company. All rights reserved. Collector C++ extension by Jesse Hull and John Ellis: Copyright c 1994 by Xerox Corporation. All rights reserved. Send us your Web links If you use any parts or all of the PLT Scheme package (software, lecture notes) for one of your courses, for your research, or for your work, we would like to know about it. Furthermore, if you use it and publicize the fact on some Web page, we would like to link to that page. Please drop us a line at [email protected] . Evidence of interest helps the DrScheme Project to maintain the necessary intellectual and financial support. We appreciate your help. Thanks Some typesetting macros were originally taken from Julian Smart’s Reference Manual for wxWindows 1.60: a portable C++ GUI toolkit .
Background image of page 2
Contents 1 Overview 1 1.1 CGC versus 3m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Writing MzScheme Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2.1 CGC Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2.2 3m Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 Embedding MzScheme into a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3.1 CGC Embedding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3.2 3m Embedding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.4 MzScheme and Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.5 MzScheme, Unicode, Characters, and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.6 Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2 Values and Types 9 2.1 Standard Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.2 Global Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.3 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.4 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3 Memory Allocation 18 3.1 Cooperating with 3m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.1.1 Tagged Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.1.2 Local Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.1.3 Local Pointers and mzc --xform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.1.4 Guiding mzc --xform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.2 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 i
Background image of page 3

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

View Full Document Right Arrow Icon
CONTENTS CONTENTS 4 Namespaces and Modules 30 4.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 5 Procedures 32 5.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 6 Evaluation 34 6.1 Top-level Evaluation Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 6.2 Tail Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 6.3 Multiple Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 6.4 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 7 Exceptions and Escape Continuations 38 7.1 Temporarily Catching Error Escapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 7.2 Enabling and Disabling Breaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 7.3 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 8 Threads 45 8.1 Integration with Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 8.2 Allowing Thread Switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 8.3 Blocking the Current Thread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 8.4 Threads in Embedded MzScheme with Event Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 8.4.1 Callbacks for Blocked Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 8.5 Sleeping by Embedded MzScheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 8.6 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 9 Parameterizations 55 9.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 10 Continuation Marks 58 10.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 11 String Encodings 59 ii
Background image of page 4
CONTENTS CONTENTS 11.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 12 Bignums, Rationals, and Complex Numbers 62 12.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 13 Ports and the Filesystem 65 13.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 14 Structures 76 14.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 15 Security Guards 78 15.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 16 Custodians 79 16.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 17 Miscellaneous Utilities 81 17.1 Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 18 Flags and Hooks 85 License 86 Index 90 iii
Background image of page 5

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

View Full Document Right Arrow Icon
CONTENTS CONTENTS iv
Background image of page 6
1. Overview
Background image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}