home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Science / Science.zip / schem742.zip / doc / user.INF (.txt) < prev   
OS/2 Help File  |  1996-04-16  |  138KB  |  4,083 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Title page ΓòÉΓòÉΓòÉ
  3.  
  4.                             MIT Scheme User's Manual
  5.  
  6.                                   Edition 1.52
  7.  
  8.                              for Scheme Release 7.4
  9.  
  10.                                   16 April 1996
  11.  
  12.                                  by Stephen Adams
  13.  
  14.                                    Chris Hanson
  15.  
  16.                              and the MIT Scheme Team
  17.  
  18. Copyright (C) 1991-96 Massachusetts Institute of Technology 
  19.  
  20. This material was developed by the Scheme project at the Massachusetts 
  21. Institute of Technology, Department of Electrical Engineering and Computer 
  22. Science.  Permission to copy this document, to redistribute it, and to use it 
  23. for any purpose is granted, subject to the following restrictions and 
  24. understandings. 
  25.  
  26.    1. Any copy made of this document must include this copyright notice in 
  27.       full. 
  28.  
  29.    2. Users of this document agree to make their best efforts (a) to return to 
  30.       the MIT Scheme project any improvements or extensions that they make, so 
  31.       that these may be included in future releases; and (b) to inform MIT of 
  32.       noteworthy uses of this document. 
  33.  
  34.    3. All materials developed as a consequence of the use of this document 
  35.       shall duly acknowledge such use, in accordance with the usual standards 
  36.       of acknowledging credit in academic research. 
  37.  
  38.    4. MIT has made no warrantee or representation that the contents of this 
  39.       document will be error-free, and MIT is under no obligation to provide 
  40.       any services, by way of maintenance, update, or otherwise. 
  41.  
  42.    5. In conjunction with products arising from the use of this material, there 
  43.       shall be no use of the name of the Massachusetts Institute of Technology 
  44.       nor of any adaptation thereof in any advertising, promotional, or sales 
  45.       literature without prior written consent from MIT in each case. 
  46.  
  47.  
  48. ΓòÉΓòÉΓòÉ 2. Top ΓòÉΓòÉΓòÉ
  49.  
  50. Scheme is the UnCommon Lisp.  This Info file is the user's guide for the MIT 
  51. implementation of Scheme.  It describes how to install and run MIT Scheme, how 
  52. to execute and compile Scheme programs, and how to use Scheme with Edwin and 
  53. GNU Emacs. 
  54.  
  55.  
  56. ΓòÉΓòÉΓòÉ 3. Introduction ΓòÉΓòÉΓòÉ
  57.  
  58. This document describes how to install and use MIT Scheme, the UnCommon Lisp. 
  59. It gives installation instructions for all of the platforms that we support; 
  60. complete documentation of the command-line options and environment variables 
  61. that control how Scheme works; and rudimentary descriptions of how to interact 
  62. with the evaluator, compile and debug programs, and use the editor.  Some 
  63. additional material, including the release notes, is included as appendices. 
  64.  
  65. This document discusses many operating-system specific features of the MIT 
  66. Scheme implementation.  In order to simplify the discussion, we use 
  67. abbreviations to refer to some operating systems.  When the text uses the term 
  68. Unix, this means any of the Unix systems that we support, including GNU/Linux, 
  69. HP-UX, Ultrix, NeXT, and SunOS.  The term OS/2 means the IBM OS/2 operating 
  70. system, version 2.1, 2.11, or 3.0 Warp.  We use the term Windows to 
  71. collectively refer to the Microsoft Windows operating systems: Windows 3.1, 
  72. Windows 95, and Windows NT.  We use the term PC to refer to any computer 
  73. running OS/2 or Windows.  Thus we consider a PC to be a system with a dos-like 
  74. file system, using backslashes for directory separators, drive letters, cr-lf 
  75. line termination, and (potentially) the hideous 8.3 short filenames. 
  76.  
  77. The primary distribution site for this software is the ftp server 
  78. `swiss-ftp.ai.mit.edu'.  Although our software is distributed from other sites 
  79. and in other media, the complete distribution and the most recent release is 
  80. always available at our site. 
  81.  
  82. To report bugs, send email to `bug-cscheme@zurich.ai.mit.edu'. Please include 
  83. the output of the identify-world procedure (see Basics of Starting Scheme), so 
  84. we know what version of the system you are using. 
  85.  
  86.  
  87. ΓòÉΓòÉΓòÉ 4. Installation ΓòÉΓòÉΓòÉ
  88.  
  89. This chapter describes how to install MIT Scheme release 7.4.  The release is 
  90. supported under several different operating systems: Unix, OS/2, and Windows. 
  91. Read the section detailing the installation for the operating system that you 
  92. are using. 
  93.  
  94. If you are installing on an HP 9000 series 700 or 800, you should also read 
  95. HP-PA Installation. 
  96.  
  97.  
  98. ΓòÉΓòÉΓòÉ 4.1. Unix Installation ΓòÉΓòÉΓòÉ
  99.  
  100. We will use as an example the installation for GNU/Linux.  The installation for 
  101. other Unix systems is similar.  If you are installing on an HP 9000 series 700 
  102. or 800, see also HP-PA Installation. 
  103.  
  104. MIT Scheme is distributed as a compressed `tar' file.  The tar file contains a 
  105. single directory, called `dist-7.4', and that directory contains subdirectories 
  106. `bin', `etc', and `lib'.  The `bin' subdirectory contains two executable files, 
  107. `scheme' and `bchscheme'.  The `etc' subdirectory contains several files that 
  108. are used during the installation process.  The `lib' subdirectory contains 
  109. several files and subdirectories that Scheme uses while it is executing. 
  110.  
  111. The goal of the installation is to put the executable files in a directory 
  112. where they will be executed as commands, and to put the library files in some 
  113. convenient place where Scheme can find them. 
  114.  
  115.      First unpack the distribution: 
  116.  
  117.             gzip -cd linux.tar.gz | tar xvf -
  118.  
  119.       If you do not have the `gzip' program: we have built executables of this 
  120.       program for each of the machines that we support.  Either use the 
  121.       executable that we have already built, or else get the gzip sources (from 
  122.       us or from numerous other sources) and build it yourself. 
  123.  
  124.      Next, go to the directory that you just unpacked: 
  125.  
  126.             cd dist-7.4
  127.  
  128.       The easiest way to install the files is to use the "install.sh" shell 
  129.       script that we've provided in the distribution.  You will need to edit 
  130.       that script to tell it where and how you want Scheme installed.  If you 
  131.       want to do something more complicated, or if the script can't easily be 
  132.       made to work for your system, use the script as a guide to installation. 
  133.  
  134.      The script assumes there is no pre-existing installation of MIT Scheme on 
  135.       your system.  If there is, you may need to edit the script, or delete the 
  136.       existing version (particularly the contents of 
  137.       `/usr/local/lib/mit-scheme', see the later note on editing `libdir').  If 
  138.       you have trouble deleting the binary because it is in use, try renaming 
  139.       it to `scheme.busy' and deleting it later. 
  140.  
  141.      The installation script normally uses the command `cp -pr' to copy the 
  142.       files from the distribution directory to their final locations.  You can 
  143.       change this by editing the definition of the `install' variable in the 
  144.       `install.sh' shell script.  Some versions of `cp' do not support the `p' 
  145.       option; using simply `cp -r' in this case is acceptable.  You can also 
  146.       use the `mv' command to move the files and directories into place, but 
  147.       note that most versions of `mv' require the source and destination to be 
  148.       on the same physical device. 
  149.  
  150.      The installation script may try to make some symbolic links during the 
  151.       installation.  This is normally done using the command `ln -s'. If your 
  152.       system doesn't support symbolic links, or if you prefer to copy or 
  153.       hard-link files, change the definition of the `link' variable in the 
  154.       shell script. 
  155.  
  156.      For many systems, a standard place to put executable files is the 
  157.       directory `/usr/local/bin'.  If this is true for your system, we suggest 
  158.       installing the executables there.  Otherwise, you probably have some 
  159.       other directory that serves the same purpose; edit `install.sh' and 
  160.       change the definition of the shell variable `bindir' to be this other 
  161.       directory. 
  162.  
  163.      Normally, auxiliary files are stored in the directory 
  164.       `/usr/local/lib/mit-scheme/'.  If you can, we suggest that you create 
  165.       such a directory and install these files there.  Otherwise, create a 
  166.       directory somewhere else and edit the installation script to change the 
  167.       value of the variable `libdir' to be this directory. 
  168.  
  169.      If you have GNU Emacs installed on your system, the installation script 
  170.       will attempt to automatically determine values for the script variables 
  171.       `infodir', `emacslisp', and `movemail'.  If it guesses incorrectly, you 
  172.       will have to override the guesses by editing the script with appropriate 
  173.       values. 
  174.  
  175.      Once you are satisfied that the `install.sh' script is correct, execute 
  176.       it: 
  177.  
  178.             ./install.sh
  179.  
  180.      After `install.sh' finishes, you can delete the `dist-7.4' directory that 
  181.       you unpacked earlier. 
  182.  
  183.       You should now be able to run MIT Scheme by typing 
  184.  
  185.             scheme
  186.  
  187.       at the command line (if you use the C shell, you may have to type 
  188.       `rehash' before `scheme' will be recognized). 
  189.  
  190.  
  191. ΓòÉΓòÉΓòÉ 4.2. HP-PA Installation ΓòÉΓòÉΓòÉ
  192.  
  193. If you are using an HP 9000 series 700/800 computer (often called an HP 
  194. Precision Architecture machine, or HP-PA for short), read this section. You 
  195. should also read Unix Installation. 
  196.  
  197. Scheme has built-in code that flushes the instruction and data caches of your 
  198. machine in certain circumstances.  This code is sensitive to your computer's 
  199. model, because each model has different cache hardware. 
  200.  
  201. This distribution contains a database, called `hppacach.mod', that describes 
  202. the cache structure for each model of computer.  As of this writing, that 
  203. database contains entries for the following models: 
  204.  
  205. 705, 710, 712, 715, 720, 725, 730, 735, 750, 755, 770,
  206. 816, 834, 835, 850, 867, 877
  207.  
  208. If you have a model that is not in the database, Scheme will not run; instead 
  209. it will print an error message informing you of this fact, and stop.  If this 
  210. happens, you must add an entry to the database. This must be done once, at 
  211. installation, for each new model. 
  212.  
  213. Here is the procedure for updating the database: 
  214.  
  215.      Run the program `hppacach' that is included in the distribution. You must 
  216.       give this program the filename of the database file as an argument. 
  217.       Normally the database file name is 
  218.       `/usr/local/lib/mit-scheme/hppacach.mod', but if you install Scheme in a 
  219.       non-standard place it will be different.  For example, if you install 
  220.       Scheme as `/usr/foo/mit-scheme/', the database file is called 
  221.       `/usr/foo/mit-scheme/hppacach.mod'. 
  222.  
  223.      Assuming that Scheme is installed in the normal place, update the 
  224.       database by becoming the super-user and executing the following commands 
  225.       on your machine: 
  226.  
  227.             cd /usr/local/lib/mit-scheme
  228.             ./hppacach -update hppacach.mod
  229.  
  230.       The reason that you must be super-user is that `hppacach' needs to read 
  231.       the device `/dev/kmem' to get the information that it needs. Normally, 
  232.       `/dev/kmem' is readable only by the super-user, or by users in group sys. 
  233.       Thus, becoming super-user is the easiest way to read this information. 
  234.       An alternative method for doing this is to change the permissions of the 
  235.       `hppacach' program so that it is in group sys, and to turn on its "set 
  236.       group ID on exec" permission bit, but since this also requires you to be 
  237.       super-user, you might as well just execute the program as the super-user. 
  238.  
  239.       Please note that you must execute this program on the computer whose 
  240.       model you wish to add to the database.  Also, if you wish to add several 
  241.       models to the database, you must execute the program once on each model. 
  242.       If you have several computers that are all of the same model, you need 
  243.       only update the database once from one of the computers; thereafter all 
  244.       of the other computers of that model will work. 
  245.  
  246.      If you add a new model to the database, we'd appreciate it if you would 
  247.       send us the model information, so that we can update the copy of the 
  248.       database that we distribute to others.  This can be done using the 
  249.       `hppacach' program, as follows: 
  250.  
  251.             cd /usr/local/lib/mit-scheme
  252.             ./hppacach -print hppacach.mod > model-7xx
  253.  
  254.       (If you have previously updated the database, you do not need to be 
  255.       super-user to execute this command.)  The resulting file, `model-7xx' in 
  256.       this example, is the model information for the machine that you executed 
  257.       the command on; it is C code that we can use to update our copy of the 
  258.       database.  Send the model information for each new model to us by 
  259.       electronic mail at bug-cscheme@zurich.ai.mit.edu.  Thanks! 
  260.  
  261.  
  262. ΓòÉΓòÉΓòÉ 4.3. OS/2 Installation ΓòÉΓòÉΓòÉ
  263.  
  264. This section describes how to install MIT Scheme on a machine running OS/2 2.1 
  265. or OS/2 Warp 3.0. 
  266.  
  267.  
  268. ΓòÉΓòÉΓòÉ 4.3.1. Prerequisites ΓòÉΓòÉΓòÉ
  269.  
  270. The Scheme files use about 20 megabytes of disk space when installed. An 
  271. additional 5 megabytes of disk space is required during installation. After 
  272. installation, you can reduce the amount of disk space required by deleting some 
  273. files (see Image Files for OS/2 Installation). 
  274.  
  275. MIT Scheme requires a fair amount of RAM to run well.  We haven't tried running 
  276. this on any machine with less than 36 megabytes, so we don't have any hard data 
  277. on what the smallest practical amount of RAM is.  However, for running Scheme 
  278. under OS/2 Warp, 8 megabytes is probably the least you should consider, and 12 
  279. megabytes is probably comfortable.  If you want to use the Scheme compiler or 
  280. the Edwin text editor, you should have at least 16 megabytes of RAM. 
  281.  
  282. MIT Scheme has been tested only on OS/2 Warp 3.0, but it should also run under 
  283. OS/2 versions 2.1 and 2.11.  It was compiled using IBM Visual Age C++ version 
  284. 3.0 and the OS/2 Toolkit version 3.0. 
  285.  
  286.  
  287. ΓòÉΓòÉΓòÉ 4.3.2. OS/2 Installation Procedure ΓòÉΓòÉΓòÉ
  288.  
  289. After unpacking the zip file, `os2.zip', you will have these directories 
  290. containing the following files: 
  291.  
  292.  `readme' 
  293.            This file. 
  294.  
  295.  `bin\' 
  296.            The executable programs `scheme.exe' and `bchschem.exe'. 
  297.  
  298.  `doc\' 
  299.            Documentation files.  Two files, the MIT Scheme User's Manual and 
  300.            the MIT Scheme Reference Manual, are provided in `.inf' format; 
  301.            these files can be read with the OS/2 `view' command. 
  302.  
  303.  `etc\' 
  304.            Installation command files.  These are scripts that will be used 
  305.            during the installation procedure. 
  306.  
  307.  `icons\' 
  308.            A directory containing some useful icons. 
  309.  
  310.  `lib\' 
  311.            A directory containing the data files needed by Scheme when it is 
  312.            running. 
  313.  
  314.  Perform the following steps to install Scheme: 
  315.  
  316.    1. Run the command file `etc\mkbands.cmd'.  This creates the image files 
  317.       `compiler.com', `edwin.com', and `all.com', and deletes the files 
  318.       `compdel.com' and `eddel.com'. 
  319.  
  320.    2. Move the executable files `scheme.exe' and `bchschem.exe' from `bin\' to 
  321.       any directory that appears in your `PATH' environment variable. 
  322.       Depending on your needs, you may want to keep only one of these files; 
  323.       each of these files is about 450 kilobytes and chances are you'll only be 
  324.       using one of them.  If you keep only `bchschem.exe' we recommend you 
  325.       rename it to `scheme.exe'.  Of course, you can also keep both programs 
  326.       around if you think you might use them both. 
  327.  
  328.       The only difference between these two programs is in how they handle 
  329.       garbage collection.  `scheme.exe' allocates two memory heaps, and copies 
  330.       objects between the heaps to preserve them.  This means that most of the 
  331.       time the other heap is occupying valuable memory but doesn't hold any 
  332.       interesting data.  `bchschem.exe' allocates only one memory heap, creates 
  333.       a disk file during garbage collection, copies objects into the file, then 
  334.       copies them back into memory. (See Memory Usage, for more detail about 
  335.       this topic.) 
  336.  
  337.       These programs provide you with some important performance trade-offs. If 
  338.       you have plenty of memory and want the best performance, use 
  339.       `scheme.exe'.  If you don't have enough memory, or if you want to use 
  340.       less memory and will accept slower performance, use `bchschem.exe'.  One 
  341.       way to tell that you don't have enough memory is to run `scheme.exe' for 
  342.       a while and see if your machine is paging during garbage collection. 
  343.  
  344.       You might consider trying to use `scheme.exe' and letting the operating 
  345.       system's paging handle the lack of RAM.  But usually you will find that 
  346.       using `bchschem.exe' without paging is much faster than using 
  347.       `scheme.exe' with paging.  Of course, if you are using `bchschem.exe' and 
  348.       you're still paging, there's nothing you can do to win. 
  349.  
  350.    3. You may move the `lib\' directory anywhere you like.  You may rename it 
  351.       to anything you like.  (Here at MIT, we use `c:\scheme\lib'.)  After you 
  352.       have chosen where it will be located, set the `MITSCHEME_LIBRARY_PATH' 
  353.       environment variable in `config.sys' to be that location. 
  354.  
  355.       For example, if you decide to store the directory as `c:\schdata', you 
  356.       would add the following to `config.sys': 
  357.  
  358.             SET MITSCHEME_LIBRARY_PATH=C:\SCHDATA
  359.  
  360.       (Remember that you must reboot OS/2 after editing `config.sys' in order 
  361.       for the changes to take effect.) 
  362.  
  363.       You can override the setting of this environment variable with the 
  364.       `-library' command-line option to Scheme, for example: 
  365.  
  366.             scheme -library d:\scheme\lib
  367.  
  368.       If you supply a `-library' option, it is not necessary to have the 
  369.       environment variable defined.  For example, instead of editing 
  370.       `config.sys', you might create a `.cmd' file to invoke Scheme and pass it 
  371.       the `-library' option automatically. 
  372.  
  373.    4. Optional: Move the `doc\' directory anywhere you like, or delete it if 
  374.       you do not want to keep the documentation. 
  375.  
  376.    5. Optional: Run the command file `etc\mkfolder.cmd' to create a folder 
  377.       containing icons to invoke Scheme.  You must give this command file a 
  378.       single argument, which is the full path name of the executable file that 
  379.       you will use.  For example, if you stored the file `scheme.exe' as 
  380.       `c:\scheme\bin\scheme.exe', then you would invoke this command file as 
  381.       follows: 
  382.  
  383.             etc\mkfolder c:\scheme\bin\scheme.exe
  384.  
  385.       This will create a folder containing four icons, called `Scheme', 
  386.       `Edwin', `Liar', and `All', which correspond to the image files 
  387.       `runtime.com', `edwin.com', `compiler.com', and `all.com'.  If you decide 
  388.       to delete any of the image files, you can delete the corresponding icons 
  389.       as well. 
  390.  
  391.    6. Optional: The `icons\' directory contains some Scheme-ish icon files.  If 
  392.       you don't like the icons created by the `etc\mkfolder' command, you can 
  393.       use these icon files to change their appearance. 
  394.  
  395.    7. Optional: Consider setting some of other environment variables described 
  396.       below. 
  397.  
  398.  
  399. ΓòÉΓòÉΓòÉ 4.3.3. Image Files ΓòÉΓòÉΓòÉ
  400.  
  401. Scheme stores its runtime environment in a binary image file, which is directly 
  402. loaded into the Scheme process.  An image file is a snapshot of Scheme's memory 
  403. taken at a particular time (you can create your own image files using the 
  404. disk-save procedure; see World Images).  This distribution comes with four 
  405. different image files, each of which contains different mixes of programs. 
  406. These image files are stored in the `lib\' directory. 
  407.  
  408.    1. `runtime.com' is the basic runtime environment with no other programs 
  409.       loaded.  This is the smallest image file.  All other image files are 
  410.       supersets of this file.  This is the default image file that is used when 
  411.       Scheme starts up, unless it is overridden by a command-line option. 
  412.  
  413.    2. `compiler.com' contains the basic runtime environment and the Liar 
  414.       native-code compiler.  This is the image file that is loaded when Scheme 
  415.       is started with the `-compiler' command-line option. 
  416.  
  417.    3. `edwin.com' contains the basic runtime environment and the Edwin text 
  418.       editor.  This is the image file that is loaded when Scheme is started 
  419.       with the `-edwin' command-line option. 
  420.  
  421.    4. `all.com' contains the basic runtime environment, the Liar compiler, and 
  422.       the Edwin editor.  This is the largest of the image files. There is no 
  423.       command-line option corresponding to this image file, but the following 
  424.       options can be used to load this file: 
  425.  
  426.             -large -constant 1600 -band all.com
  427.  
  428.  You can delete any of these files that you aren't going to use (these image 
  429.  files take up a lot of disk space!).  However, keep in mind that you need at 
  430.  least one image file to run Scheme at all. 
  431.  
  432.  
  433. ΓòÉΓòÉΓòÉ 4.3.4. Documentation ΓòÉΓòÉΓòÉ
  434.  
  435. Documentation for Scheme is included with this release, in the directory 
  436. `doc\'.  It consists of the following files: 
  437.  
  438.      `user.inf' is the MIT Scheme User's Manual, which describes how to run 
  439.       and use Scheme.  It describes all of the environment variables and 
  440.       command-line options, how to run the compiler and editor, etc. 
  441.  
  442.      `scheme.inf' is the MIT Scheme Reference Manual, which documents the 
  443.       programming language and the runtime library.  This is a large and 
  444.       detailed document for writing programs. 
  445.  
  446.      `console.txt' describes the procedures that can be used to control the 
  447.       appearance of the console window (i.e. Scheme's main window). 
  448.  
  449.  Note: the User's Manual and Reference Manual are available in other forms, 
  450.  specifically: as PostScript files and as GNU Info files.  These alternate 
  451.  forms of documentation may be obtained from our ftp site, 
  452.  `swiss-ftp.ai.mit.edu'. 
  453.  
  454.  
  455. ΓòÉΓòÉΓòÉ 4.3.5. Environment Variables ΓòÉΓòÉΓòÉ
  456.  
  457. This section documents several of the environment variables that Scheme uses, 
  458. and gives an example for each one.  These are the environment variables that 
  459. must usually be defined when installing Scheme under OS/2.  For complete 
  460. documentation of all of the environment variables used by Scheme, see 
  461. Environment Variables. 
  462.  
  463. Note that environment variables are usually defined in the OS/2 `config.sys' 
  464. file.  After editing the `config.sys' file, it is necessary to reboot OS/2 
  465. before the changes will take effect. 
  466.  
  467.  MITSCHEME_LIBRARY_PATH 
  468.            says where to find Scheme's data files.  This is the only required 
  469.            environment variable (but is not required when Scheme is invoked 
  470.            with the `-library' command-line option). 
  471.  
  472.                       SET MITSCHEME_LIBRARY_PATH=C:\SCHEME\LIB
  473.  
  474.  MITSCHEME_INF_DIRECTORY 
  475.            tells Scheme where to find debugging information for the runtime 
  476.            system. The default value for this environment variable is a 
  477.            subdirectory `src\' located in the directory specified by 
  478.            `MITSCHEME_LIBRARY_PATH'. 
  479.  
  480.                       SET MITSCHEME_INF_DIRECTORY=C:\SCHEME\LIB\SRC
  481.  
  482.  TEMP 
  483.            tells Scheme the name of a directory where it can store temporary 
  484.            files. 
  485.  
  486.                       SET TEMP=C:\TMP
  487.  
  488.  HOME 
  489.            tells Scheme where your "home" directory is located.  This is where 
  490.            Scheme looks for init files, and it is also what the `~/' (or `~\\') 
  491.            filename prefix expands to.  If not specified, Scheme uses the root 
  492.            directory of the current drive. 
  493.  
  494.                       SET HOME=C:\CPH
  495.  
  496.  USER 
  497.            tells Scheme your user name.  This is used for several purposes, 
  498.            including the name that will be used as your email address. 
  499.  
  500.                       SET USER=cph
  501.  
  502.  SHELL 
  503.            tells Edwin what shell program to use in shell buffers and for 
  504.            running shell commands.  If not specified, this defaults to the 
  505.            standard OS/2 shell, `cmd.exe'. 
  506.  
  507.                       SET SHELL=C:\LOCAL\PROG\4OS2251\4OS2.EXE
  508.  
  509.  
  510. ΓòÉΓòÉΓòÉ 4.4. Windows Installation ΓòÉΓòÉΓòÉ
  511.  
  512. This section describes how to install MIT Scheme on Windows 3.1, Windows 95 and 
  513. Windows NT.  Note that we have tested MIT Scheme only on Windows NT 3.10, 
  514. Windows 3.1 and Windows 95.  It should run under Windows NT 3.51.  It was 
  515. compiled using the Microsoft's MSTOOLS compiler that comes with Windows NT 
  516. 3.10. 
  517.  
  518.  
  519. ΓòÉΓòÉΓòÉ 4.4.1. Prerequisites ΓòÉΓòÉΓòÉ
  520.  
  521. The Scheme files use about 20 megabytes of disk space when installed. An 
  522. additional 5 megabytes of disk space is required during installation.  After 
  523. installation, you can reduce the amount of disk space required by deleting some 
  524. files (see "Image Files" below). 
  525.  
  526. MIT Scheme requires a fair amount of RAM to run well.  We haven't tried running 
  527. this on any machine with less than 32 megabytes, so we don't have any hard data 
  528. on what the smallest practical amount of RAM is.  However, for running Scheme 
  529. under Windows 3.1, 8 megabytes is probably the least you should consider, and 
  530. 12 megabytes is probably comfortable.  If you want to use the Scheme compiler 
  531. or the Edwin text editor, you should have at least 16 megabytes of RAM. 
  532.  
  533. MIT Scheme is a 32-bit program.  To run it on Windows 3.1 you need to install 
  534. the Win32s compatibility package from Microsoft.  You might already have Win32s 
  535. on your machine if another 32-bit software package installed it.  Win32s is 
  536. provided in the self-extracting zip file `pw1118.exe'.  Create a temporary 
  537. directory.  Copy `pw1118.exe' into the directory, change into the directory and 
  538. run `pw1118'.  This will create three files.  Follow the instructions in 
  539. `readme.txt'. 
  540.  
  541.  
  542. ΓòÉΓòÉΓòÉ 4.4.2. Windows Installation Procedure ΓòÉΓòÉΓòÉ
  543.  
  544. Create a directory where you would like Scheme to be installed.  We suggest 
  545. `c:\scheme'. From now on we will call this directory the Scheme root directory. 
  546. Change to this directory and unpack `bin.zip': 
  547.  
  548. unzip bin.zip
  549.  
  550. You will have the following files and directories: 
  551.  
  552.  `readme' 
  553.            These installation instructions. 
  554.  
  555.  `bin\' 
  556.            The executable programs `scheme.exe' and `bchschem.exe', and the 
  557.            libraries 
  558.            `scheme16.dll', `scheme31.dll' and `scheme32.dll'. 
  559.  
  560.  `doc\' 
  561.            Documentation files.  Three files, the MIT Scheme Users' Manual, the 
  562.            MIT Scheme Reference Manual, and the Revised^4 Report on the 
  563.            Algorithmic Language Scheme, are provided in Windows Help (`.hlp') 
  564.            format. 
  565.  
  566.  `etc\' 
  567.            Installation command files. 
  568.  
  569.  `lib\' 
  570.            A directory containing the data files needed by Scheme when it is 
  571.            running. 
  572.  
  573.  If you do not get this directory structure you may be using a version of 
  574.  `unzip' that does not understand directory trees.  In this case use the 
  575.  version of `unzip' that comes with MIT Scheme, in the same directory as the 
  576.  `.zip' files. 
  577.  
  578.  Perform the following steps to install Scheme: 
  579.  
  580.    1. Build the bands. Make sure that you are in the Scheme root directory (you 
  581.       should be there already).  Run the following command files 
  582.  
  583.             etc\mk_comp.bat
  584.             etc\mk_edwin.bat
  585.             etc\mk_all.bat
  586.  
  587.       This will create the image files `lib\compiler.com', `lib\edwin.com', and 
  588.       `lib\all.com'.  You may now delete the files `lib\compdel.com' and 
  589.       `lib\eddel.com'. 
  590.  
  591.       If you are running Windows 3.1 you cannot run Scheme from the command 
  592.       line.  You need to make a folder containing icons to run Scheme, as 
  593.       described below, and then run the following icons in turn: `Build 
  594.       COMPILER.COM band', `Build EDWIN.COM band' and `Build ALL.COM band'. 
  595.  
  596.    2. You may move the executable files `scheme.exe' and `bchschem.exe' and the 
  597.       three 
  598.       `schemenn.dll' files from `bin\' to any directory that appears in your 
  599.       `PATH', though we suggest that you leave them put. 
  600.  
  601.       Depending on your needs, you may want to keep only one of the 
  602.       `scheme.exe' or 
  603.        `bchschem.exe' files; each of these files is about 550 kilobytes and 
  604.       chances are you'll only be using one of them. If you keep only 
  605.       `bchschem.exe' we recommend you rename it to `scheme.exe'.  Of course, 
  606.       you can also keep both programs around if you think you might use them 
  607.       both. 
  608.  
  609.       The only difference between these two programs is in how they handle 
  610.       garbage collection.  `scheme.exe' allocates two memory heaps, and copies 
  611.       objects between the heaps to preserve them.  This means that most of the 
  612.       time the other heap is occupying valuable memory but doesn't hold any 
  613.       interesting data.  `bchschem.exe' allocates only one memory heap, creates 
  614.       a disk file during garbage collection, copies objects into the file, then 
  615.       copies them back into memory. (See Memory Usage, for more detail about 
  616.       this topic.) 
  617.  
  618.       These programs provide you with some important performance trade-offs. If 
  619.       you have plenty of memory and want the best performance, use 
  620.       `scheme.exe'.  If you don't have enough memory, or if you want to use 
  621.       less memory and will accept slower performance, use `bchschem.exe'.  One 
  622.       way to tell that you don't have enough memory is to run `scheme.exe' for 
  623.       a while and see if your machine is paging during garbage collection. 
  624.  
  625.       You might consider trying to use `scheme.exe' and letting the operating 
  626.       system's paging handle the lack of RAM.  But usually you will find that 
  627.       using `bchschem.exe' without paging is much faster than using 
  628.       `scheme.exe' with paging.  Of course, if you are using `bchschem.exe' and 
  629.       you're still paging, there's nothing you can do to win. 
  630.  
  631.    3. You may move the `lib\' directory anywhere you like.  You may rename it 
  632.       to anything you like.  (Here at MIT, we use `c:\scheme\lib'.)  After you 
  633.       have chosen where it will be located, set the `MITSCHEME_LIBRARY_PATH' 
  634.       environment variable to be that location. 
  635.  
  636.       For example, if you decide to store the directory as `d:\schdata', you 
  637.       would add the following to `autoexec.bat': 
  638.  
  639.             SET MITSCHEME_LIBRARY_PATH=D:\SCHDATA
  640.  
  641.       You can override the setting of this environment variable with the 
  642.       `-library' command-line option to Scheme, for example: 
  643.  
  644.             scheme -library d:\schdata
  645.  
  646.       If you always supply a `-library' option, it is not necessary to have the 
  647.       environment variable defined.  For example, instead of editing 
  648.       `autoexec.bat', you might create a `.bat' file or a shortcut (icon) to 
  649.       invoke Scheme and pass it the `-library' option automatically. 
  650.  
  651.    4. Optional: Move the `doc' directory anywhere you like, or delete it if you 
  652.       do not want to keep the documentation. 
  653.  
  654.    5. Create a folder containing shortcuts (icons) to invoke Scheme. Run Scheme 
  655.       and load the file `etc\pmgrp.scm'. On Windows 95 and windows NT you can 
  656.       run scheme from the command line: 
  657.  
  658.             bin\scheme -library lib -load etc\pmgrp
  659.  
  660.       On Windows 3.1 you have to use the `File | Run..' menu option of the 
  661.       Program Manager or File Manager and enter the full paths: 
  662.  
  663.             c:\scheme\bin\scheme -library c:\scheme\lib -load c:\scheme\etc\pmgrp.scm
  664.  
  665.       This will create a folder called `MIT Scheme 7.4.2' containing icons for 
  666.       running Scheme and for reading the help files.  The icons called 
  667.       `Scheme', `Edwin', `Liar', and `All', correspond to running Scheme with 
  668.       the image files `runtime.com', `edwin.com', `compiler.com', and 
  669.       `all.com'.  If you decide to delete any of the image files, you can 
  670.       delete the corresponding icons as well. 
  671.  
  672.       There is a bug in Windows 95 that prevents the Edwin shortcut from being 
  673.       created correctly.  To get around this problem, we have created the 
  674.       shortcut with an incorrect command line.  You have to manually edit the 
  675.       shortcut to change the curly braces on the command line into parentheses. 
  676.       The command line reads 
  677.  
  678.             ...  -eval {edit}
  679.  
  680.       but should read 
  681.  
  682.             ...  -eval (edit)
  683.  
  684.    6. Optional: Consider setting some of other environment variables described 
  685.       below. 
  686.  
  687.    7. The two files `w32rtbci.zip' and `w32edbci.zip' contain debugging 
  688.       information for the Scheme runtime and Edwin respectively. The total 
  689.       space required for all of the debugging information is about 8 megabytes. 
  690.       The runtime debugging information is the more useful as it allows the 
  691.       debugger to give you source code level information on all of the standard 
  692.       procedures like `map' and `number->string'. 
  693.  
  694.       Debugging information can be installed by uncompressing the 
  695.       `w32rtbci.zip' and 
  696.       `w32edbci.zip' files in the `SRC' subdirectory of the library directory. 
  697.  
  698.             cd c:\scheme\lib
  699.             mkdir SRC
  700.             cd SRC
  701.             unzip w32rtbci
  702.             unzip w32rtbci
  703.  
  704.       Debugging information files can be installed in another place. 
  705.       In this case the the `MITSCHEME_INF_DIRECTORY' environment variable 
  706.       should be set in `autoexec.bat'. 
  707.  
  708.       To test that you have installed the debugging information correctly, try 
  709.       to pretty-print a compiled procedure, for example, 
  710.  
  711.             (pp pp)
  712.  
  713.       When the debugging information is installed correctly, Scheme will be 
  714.       able to find the source code for the pp procedure, and display it. 
  715.       Otherwise it will use the short opaque form, something like this: 
  716.  
  717.             #[compiled-procedure 13 ("pp" #x2) #xF #x646BF7]
  718.  
  719.  
  720. ΓòÉΓòÉΓòÉ 5. Running Scheme ΓòÉΓòÉΓòÉ
  721.  
  722. This chapter describes how to run MIT Scheme.  It also describes how you can 
  723. customize the behavior of MIT Scheme using command-line options and environment 
  724. variables. 
  725.  
  726.  
  727. ΓòÉΓòÉΓòÉ 5.1. Basics of Starting Scheme ΓòÉΓòÉΓòÉ
  728.  
  729. Usually, MIT Scheme is invoked by typing 
  730.  
  731. scheme
  732.  
  733. at your operating system's command interpreter. (Under Windows 3.1 you must use 
  734. the Program Manager's `File | Run..' command, or an icon.) Scheme will load 
  735. itself, clear the screen, and print something like this: 
  736.  
  737. Scheme saved on Monday March 25, 1996 at 2:15:03 PM
  738.   Release 7.4.2
  739.   Microcode 11.151
  740.   Runtime 14.168
  741.  
  742. This information, which can be printed again by evaluating 
  743.  
  744. (identify-world)
  745.  
  746. tells you the following version information.  `Release' is the release number 
  747. for the entire Scheme system.  This number is changed each time a new version 
  748. of Scheme is released.  An `(alpha)' or `(beta)' following the release number 
  749. indicates that this is a alpha- or beta-test release.  `Microcode' is the 
  750. version number for the part of the system that is written in C.  `Runtime' is 
  751. the version number for the part of the system that is written in Scheme. 
  752.  
  753. Following this there may be additional version numbers for specific subsystems. 
  754. `SF' refers to the scode optimization program sf, `Liar' is the native-code 
  755. compiler, `Edwin' is the Emacs-like text editor, and `Student' is the sicp 
  756. compatibility package. 
  757.  
  758. If the compiler is supported for your machine, you can invoke it by giving 
  759. Scheme the `-compiler' option: 
  760.  
  761. scheme -compiler
  762.  
  763. This option causes Scheme to use a larger constant space and heap, and to load 
  764. the world image containing the compiler. 
  765.  
  766.  
  767. ΓòÉΓòÉΓòÉ 5.2. Customizing Scheme ΓòÉΓòÉΓòÉ
  768.  
  769. You can customize your setup by using a variety of tools: 
  770.  
  771.      Command-line options. Many parameters, like memory usage and the location 
  772.       of libraries, may be varied by command-line options.  See Command-Line 
  773.       Options. 
  774.  
  775.      Command scripts or batch files. You might like to write scripts that 
  776.       invoke Scheme with your favorite command-line options.  For example, you 
  777.       might not have enough memory to run Edwin or the compiler with its 
  778.       default memory parameters (it will print something like "Not enough 
  779.       memory for this configuration" and halt when started), so you can write a 
  780.       shell script (Unix), `.bat' file (Windows), or `.cmd' file (OS/2) that 
  781.       will invoke Scheme with the appropriate `-heap' and other parameters. 
  782.  
  783.      Scheme supports init files: an init file is a file containing Scheme code 
  784.       that is loaded when Scheme is started, immediately after the 
  785.       identification banner, and before the input prompt is printed.  This file 
  786.       is stored in your home directory, which is normally specified by the 
  787.       `HOME' environment variable.  Under Unix, the file is called 
  788.       `.scheme.init'; on the PC it is called `scheme.ini'. 
  789.  
  790.       In addition, when Edwin starts up, it loads a separate init file from 
  791.       your home directory into the Edwin environment.  This file is called 
  792.       `.edwin' under Unix, and `edwin.ini' on the PC. 
  793.  
  794.       You can use both of these files to define new procedures or commands, or 
  795.       to change defaults in the system. 
  796.  
  797.       The `-no-init-file' command-line option causes Scheme to ignore the 
  798.       `.scheme.init' file (see Command-Line Options). 
  799.  
  800.      Environment variables.  Most microcode parameters, and some runtime 
  801.       system and Edwin parameters, can be specified by means of environment 
  802.       variables.  See Environment Variables. 
  803.  
  804.      Icons. Under OS/2 and Windows it is possible to create icons that invoke 
  805.       Scheme with different parameters. 
  806.  
  807.  
  808. ΓòÉΓòÉΓòÉ 5.3. Memory Usage ΓòÉΓòÉΓòÉ
  809.  
  810. Some of the parameters that can be customized determine how much memory Scheme 
  811. uses and how that memory is used.  This section describes how Scheme's memory 
  812. is organized and used; subsequent sections describe command-line options and 
  813. environment variables that you can use to customize this usage for your needs. 
  814.  
  815. Scheme uses four kinds of memory: 
  816.  
  817.      A stack that is used for recursive procedure calls, 
  818.  
  819.      A heap that is used for dynamically allocated objects, like `cons' cells 
  820.       and strings. Storage used for objects in the heap that become 
  821.       unreferenced is eventually reclaimed by garbage collection. 
  822.  
  823.      A constant space that is used for allocated objects, like the heap. 
  824.       Unlike the heap, storage used for objects in constant space is not 
  825.       reclaimed by garbage collection. Constant space is used for objects that 
  826.       are essentially permanent, like procedures in the runtime system. 
  827.  
  828.      Some extra storage that is used by the microcode (the part of the system 
  829.       that is implemented in C). 
  830.  
  831.  All kinds of memory except the last may be controlled either by command-line 
  832.  options or by environment variables. 
  833.  
  834.  MIT Scheme uses a two-space copying garbage collector for reclaiming storage 
  835.  in the heap.  There are two versions of Scheme which handle garbage collection 
  836.  differently.  The standard Scheme, called `scheme' under Unix and `scheme.exe' 
  837.  on the PC, has two heaps, one for each "space".  An alternative, called 
  838.  `bchscheme' under Unix and `bchschem.exe' on the PC, has one heap and uses a 
  839.  disk file for the other "space", thus trading memory usage against garbage 
  840.  collection speed. 
  841.  
  842.  The total storage required by `scheme' is: 
  843.  
  844.   stack + (constant + 2*heap) + extra
  845.  
  846.  where stack, constant and heap are parameters that are selected when `scheme' 
  847.  starts.  For `bchscheme', which has only one heap in memory, the equation is 
  848.  
  849.   stack + (constant + heap) + extra
  850.  
  851.  Once the storage is allocated for the constant space and the heap, Scheme will 
  852.  dynamically adjust the proportion of the total that is used for constant 
  853.  space; the stack and extra microcode storage is not included in this 
  854.  adjustment.  Previous versions of MIT Scheme needed to be told the amount of 
  855.  constant space that was required when loading bands with the `-band' option. 
  856.  Dynamic adjustment of the heap and constant space avoids this problem; now all 
  857.  that is required is that the total space be sufficient. 
  858.  
  859.  The Scheme expression `(print-gc-statistics)' shows how much heap and constant 
  860.  space is available (see Garbage Collection). 
  861.  
  862.  
  863. ΓòÉΓòÉΓòÉ 5.4. Command-Line Options ΓòÉΓòÉΓòÉ
  864.  
  865. Scheme accepts the command-line options detailed in the following sections. 
  866. The options may appear in any order, with the restriction that the microcode 
  867. options must appear before the runtime options, and the runtime options must 
  868. appear before any other arguments on the command line.  (At present, any 
  869. arguments other than these options will generate a warning message when Scheme 
  870. starts.  In the future, there will be an advertised mechanism by which the 
  871. extra arguments can be handled by user code.) 
  872.  
  873. These are the microcode options: 
  874.  
  875.  -band filename 
  876.            Specifies the initial world image file (band) to be loaded. Searches 
  877.            for filename in the working directory and the library directories, 
  878.            using the full pathname of the first readable file of that name.  If 
  879.            filename is an absolute pathname (on Unix, this means it starts with 
  880.            `/'), then no search occurs --- filename is tested for readability 
  881.            and then used directly.  If this option isn't given, the filename is 
  882.            the value of the environment variable `MITSCHEME_BAND', or if that 
  883.            isn't defined, `runtime.com'; in these cases the library directories 
  884.            are searched, but not the working directory. 
  885.  
  886.  -compiler 
  887.            This option specifies defaults appropriate for loading the compiler. 
  888.            It specifies the use of large sizes, exactly like `-large'; if the 
  889.            `-band' option is also specified, that is the only effect of this 
  890.            option.  Otherwise, the default band's filename is the value of the 
  891.            environment variable `MITSCHEME_COMPILER_BAND', if defined, or 
  892.            `compiler.com'; the library directories are searched to locate this 
  893.            file.  Note that the `-compiler' option is available only on 
  894.            machines with compiled-code support. 
  895.  
  896.  -edwin 
  897.            This option specifies defaults appropriate for loading the editor. 
  898.            It specifies the use of large sizes, exactly like `-large'; if the 
  899.            `-band' option is also specified, that is the only effect of this 
  900.            option.  Otherwise, the default band's filename is the value of the 
  901.            environment variable `MITSCHEME_EDWIN_BAND', if defined, or 
  902.            `edwin.com'; the library directories are searched to locate this 
  903.            file.  Note that the `-edwin' option is available only on machines 
  904.            with compiled-code support. 
  905.  
  906.  -large 
  907.            Specifies that large heap, constant, and stack sizes should be used. 
  908.            These are specified by the environment variables 
  909.  
  910.                       MITSCHEME_LARGE_HEAP
  911.                       MITSCHEME_LARGE_CONSTANT
  912.                       MITSCHEME_LARGE_STACK
  913.  
  914.            If this option isn't given, the small sizes are used, specified by 
  915.            the environment variables 
  916.  
  917.                       MITSCHEME_SMALL_HEAP
  918.                       MITSCHEME_SMALL_CONSTANT
  919.                       MITSCHEME_SMALL_STACK
  920.  
  921.            There are reasonable built-in defaults for all of these environment 
  922.            variables, should any of them be undefined.  Note that any or all of 
  923.            the defaults can be individually overridden by the `-heap', 
  924.            `-constant', and `-stack' options. 
  925.  
  926.            Note: the Scheme expression `(print-gc-statistics)' shows how much 
  927.            heap and constant space is available and in use ( see Garbage 
  928.            Collection). 
  929.  
  930.  -heap blocks 
  931.            Specifies the size of the heap in 1024-word blocks.  Overrides any 
  932.            default.  Normally two such heaps are allocated; `bchscheme' 
  933.            allocates only one, and uses a disk file for the other. 
  934.  
  935.  -constant blocks 
  936.            Specifies the size of constant space in 1024-word blocks.  Overrides 
  937.            any default.  Constant space holds the compiled code for the runtime 
  938.            system and other subsystems. 
  939.  
  940.  -stack blocks 
  941.            Specifies the size of the stack in 1024-word blocks.  Overrides any 
  942.            default.  This is Scheme's stack, not the Unix stack used by C 
  943.            programs. 
  944.  
  945.  -option-summary 
  946.            Causes Scheme to write an option summary to standard error.  This 
  947.            shows the values of all of the settable microcode option variables. 
  948.  
  949.  -emacs 
  950.            Specifies that Scheme is running as a subprocess of GNU Emacs.  This 
  951.            option is automatically supplied by GNU Emacs, and should not be 
  952.            given under other circumstances. 
  953.  
  954.  -interactive 
  955.            If this option isn't specified, and Scheme's standard i/o is not a 
  956.            terminal, Scheme will detach itself from its controlling terminal, 
  957.            which prevents it from getting signals sent to the process group of 
  958.            that terminal.  If this option is specified, Scheme will not detach 
  959.            itself from the controlling terminal. 
  960.  
  961.            This detaching behavior is useful for running Scheme as a background 
  962.            job.  For example, using the C shell in Unix, the following will run 
  963.            Scheme as a background job, redirecting its input and output to 
  964.            files, and preventing it from being killed by keyboard interrupts or 
  965.            by logging out: 
  966.  
  967.                       scheme < /usr/cph/foo.in >& /usr/cph/foo.out &
  968.  
  969.            This option is ignored under non-Unix operating systems. 
  970.  
  971.  -nocore 
  972.            Specifies that Scheme should not generate a core dump under any 
  973.            circumstances.  If this option is not given, and Scheme terminates 
  974.            abnormally, you will be prompted to decide whether a core dump 
  975.            should be generated. 
  976.  
  977.            This option is ignored under non-Unix operating systems. 
  978.  
  979.  -library path 
  980.            Sets the library search path to path.  This is a list of directories 
  981.            that is searched to find various library files, such as bands.  If 
  982.            this option is not given, the value of the environment variable 
  983.            `MITSCHEME_LIBRARY_PATH' is used; if that isn't defined, the default 
  984.            is used. 
  985.  
  986.            On Unix, the elements of the list are separated by colons, and the 
  987.            default value is `/usr/local/lib/mit-scheme'.  On PCs, the elements 
  988.            of the list are separated by semicolons, and the default value is 
  989.            `c:\scheme'. 
  990.  
  991.  -utabmd filename 
  992.            Specifies that filename contains the microcode tables (the microcode 
  993.            tables are information that informs the runtime system about the 
  994.            microcode's structure).  Filename is searched for in the working 
  995.            directory and the library directories.  If this option isn't given, 
  996.            the filename is the value of the environment variable 
  997.            `MITSCHEME_UTABMD_FILE', or if that isn't defined, `utabmd.bin'; in 
  998.            these cases the library directories are searched, but not the 
  999.            working directory. 
  1000.  
  1001.            `-utab' is an alternate name for the `-utabmd' option; at most one 
  1002.            of these options may be given. 
  1003.  
  1004.  -fasl filename 
  1005.            Specifies that a cold load should be performed, using filename as 
  1006.            the initial file to be loaded.  If this option isn't given, a normal 
  1007.            load is performed instead.  This option may not be used together 
  1008.            with the `-band' option.  This option is useful only for maintenance 
  1009.            and development of the MIT Scheme runtime system. 
  1010.  
  1011.  In addition to the above, `bchscheme' recognizes the following command-line 
  1012.  options, all of which specify parameters affecting how `bchscheme' uses disk 
  1013.  storage to do garbage collection: 
  1014.  
  1015.  -gc-directory directory 
  1016.            Specifies that directory should be used to create files for garbage 
  1017.            collection.  If the option is not given, the value of environment 
  1018.            variable `MITSCHEME_GC_DIRECTORY' is used instead, and if that is 
  1019.            not defined, `/tmp' is used. 
  1020.  
  1021.  -gc-file filename 
  1022.            Specifies that filename should be used for garbage collection.  If 
  1023.            the option is not given, the value of environment variable 
  1024.            `MITSCHEME_GC_FILE' is used, and if this is not defined, a unique 
  1025.            filename is generated in the directory specified with 
  1026.            `-gc-directory'. 
  1027.  
  1028.            `-gcfile' is an alias for `-gc-file'; at most one of these options 
  1029.            should be specified. 
  1030.  
  1031.  -gc-keep 
  1032.            Specifies that the gc file used for garbage collection should not be 
  1033.            deleted when Scheme terminates. The gc file is deleted only if the 
  1034.            file was created by this invocation of Scheme, and this option is 
  1035.            not set. 
  1036.  
  1037.  -gc-start-position number 
  1038.            Specifies the first byte position in gc file at which the Scheme 
  1039.            process can write.  If not given, the value of the environment 
  1040.            variable `MITSCHEME_GC_START_POSITION' is used, and if that is not 
  1041.            defined, `0' is used, meaning the beginning of the file.  The area 
  1042.            of the file used (and locked if possible) is the region between 
  1043.            `-gc-start-position' and `-gc-end-position'. 
  1044.  
  1045.  -gc-end-position number 
  1046.            Specifies the last byte position in gc file at which the Scheme 
  1047.            process can write.  If not given, the value of the environment 
  1048.            variable `MITSCHEME_GC_END_POSITION' is used, and if that is not 
  1049.            defined, the sum of the start position (as specified by 
  1050.            `-gc-start-position') and the heap size is used.  The area of the 
  1051.            file used (and locked if possible) is the region between 
  1052.            `-gc-start-position' and `-gc-end-position'. 
  1053.  
  1054.  -gc-window-size blocks 
  1055.            Specifies the size of the windows into new space during garbage 
  1056.            collection.  If this option is not given, the value of environment 
  1057.            variable `MITSCHEME_GC_WINDOW_SIZE' is used instead, and if that is 
  1058.            not defined, the value 16 is used. 
  1059.  
  1060.  The following command-line options are only used by an experimental version of 
  1061.  `bchscheme' that uses Unix System V-style shared memory, and then only if the 
  1062.  `gcdrone' program is installed in the library directory. 
  1063.  
  1064.  -gc-drone program 
  1065.            Specifies that program should be used as the drone program for 
  1066.            overlapped i/o during garbage collection.  If the option is not 
  1067.            given, the value of environment variable `MITSCHEME_GC_DRONE' is 
  1068.            used instead, and if that is not defined, `gcdrone' is used. 
  1069.  
  1070.  -gc-read-overlap n 
  1071.            Specifies that Scheme should delegate at most n simultaneous disk 
  1072.            read operations during garbage collection.  If the option is not 
  1073.            given, the value of environment variable `MITSCHEME_GC_READ_OVERLAP' 
  1074.            is used instead, and if that is not defined, `0' is used, disabling 
  1075.            overlapped reads. 
  1076.  
  1077.  -gc-write-overlap n 
  1078.            Specifies that Scheme should delegate at most n simultaneous disk 
  1079.            write operations during garbage collection.  If the option is not 
  1080.            given, the value of environment variable 
  1081.            `MITSCHEME_GC_WRITE_OVERLAP' is used instead, and if that is not 
  1082.            defined, `0' is used, disabling overlapped writes. 
  1083.  
  1084.  The following options are runtime options.  They are processed after the 
  1085.  microcode options and after the image file is loaded. 
  1086.  
  1087.  -no-init-file 
  1088.            This option causes Scheme to ignore the `~/.scheme.init' or 
  1089.            `scheme.ini' file, normally loaded automatically when Scheme starts 
  1090.            (if it exists). 
  1091.  
  1092.  -suspend-file 
  1093.            Under some circumstances Scheme can write out a file called 
  1094.            `scheme_suspend' in the user's home directory. (Under Unix, this 
  1095.            file is written when Scheme is terminated by the `SIGUSR1', 
  1096.            `SIGHUP', or `SIGPWR' signals.  Under other operating systems, this 
  1097.            file is never written.)  This file is a world image containing the 
  1098.            complete state of the Scheme process; restoring this file continues 
  1099.            the computation that Scheme was performing at the time the file was 
  1100.            written. 
  1101.  
  1102.            Normally this file is never written, but the `-suspend-file' option 
  1103.            enables writing of this file. 
  1104.  
  1105.  -eval 
  1106.            This option causes Scheme to evaluate the expressions following it 
  1107.            on the command line, up to (but not including) the next option that 
  1108.            starts with a hyphen.  The expressions are evaluated in the 
  1109.            user-initial-environment. Unless explicitly handled, errors during 
  1110.            evaluation are silently ignored. 
  1111.  
  1112.  -load 
  1113.            This option causes Scheme to load the files (or lists of files) 
  1114.            following it on the command line, up to (but not including) the next 
  1115.            option that starts with a hyphen.  The files are loaded in the 
  1116.            user-initial-environment using the default syntax table. Unless 
  1117.            explicitly handled, errors during loading are silently ignored. 
  1118.  
  1119.  
  1120. ΓòÉΓòÉΓòÉ 5.5. Environment Variables ΓòÉΓòÉΓòÉ
  1121.  
  1122. Scheme refers to many environment variables.  This section lists these 
  1123. variables and describes how each is used.  The environment variables are 
  1124. organized according to the parts of MIT Scheme that they affect. 
  1125.  
  1126. Environment variables that affect the microcode must be defined before you 
  1127. start Scheme; under Unix or Windows, others can be defined or overwritten 
  1128. within Scheme by using the set-environment-variable! procedure, e.g. 
  1129.  
  1130. (set-environment-variable! "EDWIN_FOREGROUND" "32")
  1131.  
  1132.  
  1133. ΓòÉΓòÉΓòÉ 5.5.1. Environment Variables for the Microcode ΓòÉΓòÉΓòÉ
  1134.  
  1135. These environment variables are referred to by the microcode (the executable C 
  1136. programs called `scheme' and `bchscheme' under Unix, and `scheme.exe' and 
  1137. `bchschem.exe' on the PC). 
  1138.  
  1139.  `MITSCHEME_BAND' (default: `runtime.com' on the library path) 
  1140.            The initial band to be loaded.  Overridden by `-band', `-compiler', 
  1141.            or `-edwin'. 
  1142.  
  1143.  MITSCHEME_COMPILER_BAND (default: `compiler.com' on the library path) 
  1144.            The initial band to be loaded if the `-compiler' option is given. 
  1145.            Overridden by `-band'. 
  1146.  
  1147.  MITSCHEME_EDWIN_BAND (default: `edwin.com' on the library path) 
  1148.            The initial band to be loaded if the `-edwin' option is given. 
  1149.            Overridden by `-band'. 
  1150.  
  1151.  MITSCHEME_LARGE_CONSTANT (default: `1000') 
  1152.            The size of constant space, in 1024-word blocks, if the `-large', 
  1153.            `-compiler', or `-edwin' options are given.  Overridden by 
  1154.            `-constant'.  Note: default depends on machine; on most machines it 
  1155.            is larger than `1000'. 
  1156.  
  1157.  MITSCHEME_LARGE_HEAP (default: `1000') 
  1158.            The size of the heap, in 1024-word blocks, if the `-large', 
  1159.            `-compiler', or `-edwin' options are given.  Overridden by `-heap'. 
  1160.  
  1161.  MITSCHEME_LARGE_STACK (default: `100') 
  1162.            The size of the stack, in 1024-word blocks, if the `-large', 
  1163.            `-compiler', or `-edwin' options are given.  Overridden by `-stack'. 
  1164.  
  1165.  MITSCHEME_LIBRARY_PATH 
  1166.            A list of directories.  These directories are searched, left to 
  1167.            right, to find bands and various other files. On Unix systems the 
  1168.            list is colon separated, with the default 
  1169.            `/usr/local/lib/mit-scheme'. On PC systems the list is semi-colon 
  1170.            separated with the default `c:\scheme\lib'. 
  1171.  
  1172.  MITSCHEME_SMALL_CONSTANT (default: `450') 
  1173.            The size of constant space, in 1024-word blocks, if the size options 
  1174.            are not given.  Overridden by `-constant', `-large', `-compiler', or 
  1175.            `-edwin'.  Note: default depends on machine; on most machines it is 
  1176.            larger than `450'. 
  1177.  
  1178.  MITSCHEME_SMALL_HEAP (default: `250') 
  1179.            The size of the heap, in 1024-word blocks, if the size options are 
  1180.            not given.  Overridden by `-heap', `-large', `-compiler', or 
  1181.            `-edwin'. 
  1182.  
  1183.  MITSCHEME_SMALL_STACK (default: `100') 
  1184.            The size of the stack, in 1024-word blocks, if the size options are 
  1185.            not given.  Overridden by `-stack', `-large', `-compiler', or 
  1186.            `-edwin'. 
  1187.  
  1188.  MITSCHEME_UTABMD_FILE (default: `utabmd.bin' in the library path) 
  1189.            The file containing the microcode tables.  Overridden by `-utabmd' 
  1190.            and `-utab'.  It is only necessary when re-building `runtime.com'. 
  1191.  
  1192.  
  1193. ΓòÉΓòÉΓòÉ 5.5.2. Environment Variables for bchscheme ΓòÉΓòÉΓòÉ
  1194.  
  1195. These environment variables are referred to by `bchscheme' (not by `scheme'). 
  1196.  
  1197.  MITSCHEME_GC_DIRECTORY (default: `/tmp') 
  1198.            The directory in which gc files are written.  Overridden by 
  1199.            `-gc-directory'. 
  1200.  
  1201.  MITSCHEME_GC_FILE (default: `GCXXXXXX') 
  1202.            The name of the file to use for garbage collection.  If it ends in 6 
  1203.            Xs, the Xs are replaced by a letter and process id of the scheme 
  1204.            process, thus generating a unique name.  Overridden by `-gc-file'. 
  1205.  
  1206.  MITSCHEME_GC_START_POSITION (default: `0') 
  1207.            The first position in the gc file to use.  Overridden by 
  1208.            `-gc-start-position'. 
  1209.  
  1210.  MITSCHEME_GC_END_POSITION (default: start-position+heap-size) 
  1211.            The last position in the gc file to use.  Overridden by 
  1212.            `-gc-end-position'. 
  1213.  
  1214.  MITSCHEME_GC_WINDOW_SIZE (default: `16') 
  1215.            The size in blocks of windows into new space (in the gc file). 
  1216.            Overridden by `-gc-window-size'. 
  1217.  
  1218.  The following environment variables are only used by an experimental version 
  1219.  of Bchscheme that uses Unix System V-style shared memory, and then only if the 
  1220.  `gcdrone' program is installed: 
  1221.  
  1222.  MITSCHEME_GC_DRONE (default: `gcdrone') 
  1223.            The program to use as the i/o drone during garbage collection. 
  1224.            Overridden by `-gc-drone'. 
  1225.  
  1226.  MITSCHEME_GC_READ_OVERLAP (default: `0') 
  1227.            The maximum number of simultaneous read operations. 
  1228.            Overridden by `-gc-read-overlap'. 
  1229.  
  1230.  MITSCHEME_GC_WRITE_OVERLAP (default: `0') 
  1231.            The maximum number of simultaneous write operations. 
  1232.            Overridden by `-gc-write-overlap'. 
  1233.  
  1234.  
  1235. ΓòÉΓòÉΓòÉ 5.5.3. Environment Variables for the Runtime System ΓòÉΓòÉΓòÉ
  1236.  
  1237. These environment variables are referred to by the runtime system. 
  1238.  
  1239.  HOME 
  1240.            Directory in which to look for init files.  E.g. `c:\users\joe' or 
  1241.            `/home/joe'. 
  1242.  
  1243.  TEMP 
  1244.  TMP 
  1245.            Directory for various temporary files.  `TEMP' is given preference 
  1246.            to `TMP'. 
  1247.  
  1248.  MITSCHEME_INF_DIRECTORY (default: `SRC' on the library path) 
  1249.            Directory containing the debugging information files for the Scheme 
  1250.            system.  Should contain subdirectories corresponding to the 
  1251.            subdirectories in the source tree.  For example, if its value is 
  1252.            `f:\random', runtime system debugging files will be expected in 
  1253.            `f:\random\runtime', while Edwin debugging files will be expected in 
  1254.            `f:\random\edwin'. 
  1255.  
  1256.  MITSCHEME_LOAD_OPTIONS (default: `optiondb.scm' on the library path) 
  1257.            Specifies the location of the options database file used by the 
  1258.            load-option procedure. 
  1259.  
  1260.  
  1261. ΓòÉΓòÉΓòÉ 5.5.4. Environment Variables for Edwin ΓòÉΓòÉΓòÉ
  1262.  
  1263. These environment variables are referred to by Edwin. 
  1264.  
  1265.  EDWIN_BINARY_DIRECTORY (default: `edwin/autoload' on the library path) 
  1266.            Directory where Edwin expects to find files providing autoloaded 
  1267.            facilities. 
  1268.  
  1269.  EDWIN_INFO_DIRECTORY (default: `edwin/info' on the library path) 
  1270.            Directory where Edwin expects to find files for the `info' 
  1271.            documentation subsystem. 
  1272.  
  1273.  EDWIN_ETC_DIRECTORY (default: `edwin/etc' on the library path) 
  1274.            Directory where Edwin expects to find utility programs and 
  1275.            documentation strings. 
  1276.  
  1277.  ESHELL 
  1278.            Unix and OS/2 only. Filename of the shell program to use in shell 
  1279.            buffers.  If not defined, `SHELL' is used instead. 
  1280.  
  1281.  SHELL (default: `/bin/sh' (Unix), `cmd.exe' (OS/2)) 
  1282.            Unix and OS/2 only. Filename of the shell program to use in shell 
  1283.            buffers and when executing shell commands.  Used to initialize the 
  1284.            shell-path-name editor variable. 
  1285.  
  1286.  PATH 
  1287.            Unix and OS/2 only. Used to initialize the exec-path editor 
  1288.            variable, which is subsequently used for finding programs to be run 
  1289.            as subprocesses. 
  1290.  
  1291.  DISPLAY 
  1292.            Unix running X11 only. Specifies the display on which Edwin will 
  1293.            create windows. 
  1294.  
  1295.  TERM 
  1296.            Unix terminals only. Terminal type. 
  1297.  
  1298.  LINES (default: auto-sense) 
  1299.            Unix terminals only. Number of text lines on the screen, for systems 
  1300.            that don't support `TIOCGWINSZ'. 
  1301.  
  1302.  COLUMNS (default: auto-sense) 
  1303.            Unix terminals only. Number of text columns on the screen, for 
  1304.            systems that don't support `TIOCGWINSZ'. 
  1305.  
  1306.  
  1307. ΓòÉΓòÉΓòÉ 5.5.5. Environment Variables for Windows ΓòÉΓòÉΓòÉ
  1308.  
  1309. These environment variables are specific to the Windows implementation. 
  1310.  
  1311.  MITSCHEME_FONT (default: determined by operating system) 
  1312.            A string specifying a font name and characteristics, for example, 
  1313.            `Courier New 16 bold'. Allowed characteristics are integer, 
  1314.            specifiying the font size, and the following style modifiers: 
  1315.            `bold', `italic', `regular', `underline' and `strikeout'. Note that 
  1316.            the size is the total height in pixels, and *not* the point size. 
  1317.            Thus the fonts tend to be 20-50% smaller than you might expect. You 
  1318.            should specifiy only fixed-width fonts as variable width fonts are 
  1319.            not drawn correctly. 
  1320.  
  1321.            Once in Edwin, the font can be changed with the `set-font' and 
  1322.            `set-default-font' commands. 
  1323.  
  1324.  MITSCHEME_GEOMETRY (default: `-1,-1,-1,-1') 
  1325.            Four integers separated by commas or spaces that specify the 
  1326.            placement and size of the MIT Scheme window as a 
  1327.            left,top,width,height quadruple.  The units are screen pixels, and 
  1328.            `-1' means allow the system to choose this parameter. E.g. 
  1329.            `-1,-1,500,300' places a 500 by 300 pixel window at some 
  1330.            system-determined position on the screen.  The width and height 
  1331.            include the window border and title. 
  1332.  
  1333.  MITSCHEME_FOREGROUND (default: according to desktop color scheme) 
  1334.            A value specifying the window text color.  The color is specified as 
  1335.            hex blue, green and red values (not RGB): e.g. 0xff0000 for blue. 
  1336.  
  1337.  MITSCHEME_BACKGROUND (default: according to desktop color scheme) 
  1338.            A value specifying the window background color.  See 
  1339.            `MITSCHEME_FOREGROUND'. 
  1340.  
  1341.  HOMEDRIVE 
  1342.  HOMEPATH 
  1343.            These variables are used together to indicate the user's home 
  1344.            directory.  This is the preferred way to specify the home directory. 
  1345.  
  1346.  USERNAME 
  1347.  USER 
  1348.            Specifies the login name of the user running Scheme.  This is used 
  1349.            for several different purposes.  `USERNAME' is preferred; `USER' is 
  1350.            used if `USERNAME' is not defined.  If neither of these variables is 
  1351.            defined, "nouser" is used as the user's name. 
  1352.  
  1353.  USERDIR 
  1354.            Specifies a directory that contains the home directories of users. 
  1355.            One of the places in which Scheme looks for the user's home 
  1356.            directory, by searching for a subdirectory with the user's login 
  1357.            name. 
  1358.  
  1359.  
  1360. ΓòÉΓòÉΓòÉ 5.5.6. Environment Variables for OS/2 ΓòÉΓòÉΓòÉ
  1361.  
  1362. These environment variables are specific to the OS/2 implementation. 
  1363.  
  1364.  USER 
  1365.            Specifies the login name of the user running Scheme.  This is used 
  1366.            for several different purposes.  If this variable is undefined, 
  1367.            "nouser" is used as the user's name. 
  1368.  
  1369.  USERDIR 
  1370.            Specifies a directory that contains the home directories of users. 
  1371.            One of the places in which Scheme looks for the user's home 
  1372.            directory, by searching for a subdirectory with the user's login 
  1373.            name. 
  1374.  
  1375.  
  1376. ΓòÉΓòÉΓòÉ 5.6. Starting Scheme from Windows ΓòÉΓòÉΓòÉ
  1377.  
  1378. The Windows version of MIT Scheme runs as a graphics-based application. Under 
  1379. Windows NT and Windows 95, Scheme can be started from the command line as 
  1380. described at the beginning of this chapter. 
  1381.  
  1382. Under Windows 3.1, Scheme must be run from the Program Manager or the File 
  1383. Manager.  Scheme cannot be run from the command line, because it is not a dos 
  1384. program (although some people run other shell programs in place of 
  1385. `command.com' that can run Windows applications). 
  1386.  
  1387. Shortcuts (Windows 95) or Program Manager groups and icons (Windows 3.1 and 
  1388. Windows NT) are a convenient way to start Scheme. The rest of this section 
  1389. gives some tips on how to set up shortcuts that run Scheme.  If you are 
  1390. unfamiliar with this concept you should read about it in the system help. 
  1391.  
  1392.      Under Windows NT program manager groups can be common or personal.  When 
  1393.       setting up icons in a common group it is important to make the icon 
  1394.       properties independent of the vagaries of the environment of the user who 
  1395.       is running them.  It is often worthwhile doing this under Windows 3.1 and 
  1396.       for personal groups too. 
  1397.  
  1398.      Give the shortcut an accurate Description. 
  1399.  
  1400.      Include absolute pathnames to `scheme.exe' and `bchscheme.exe' in the 
  1401.       icon Command line. 
  1402.  
  1403.      I you specify the `-library' command line option then you do not have to 
  1404.       worry about the `MITSCHEME_LIBRARY_PATH' environment variable. 
  1405.  
  1406.      Set the shortcut's Working Directory to something sensible.  On Windows 
  1407.       NT you can use `%HOMEPATH%' to make Scheme start up in the user's home 
  1408.       directory. 
  1409.  
  1410.      There are several icons available in the Scheme executable --- choose one 
  1411.       that best represents the options given on the command line. 
  1412.  
  1413.      Specifying a band that contains Edwin is not sufficient to invoke the 
  1414.       editor.  You also have to put 
  1415.  
  1416.             -eval (edit)
  1417.  
  1418.       at the end of the command line. 
  1419.  
  1420.  
  1421. ΓòÉΓòÉΓòÉ 5.7. Leaving Scheme ΓòÉΓòÉΓòÉ
  1422.  
  1423. There are several ways that you can leave Scheme: there are two Scheme 
  1424. procedures that you can call; there are several Edwin commands that you can 
  1425. execute; and there are are graphical-interface buttons (and their associated 
  1426. keyboard accelerators) that you can activate. 
  1427.  
  1428.      Two Scheme procedures that you can call.  The first is to evaluate 
  1429.  
  1430.             (exit)
  1431.  
  1432.       which will halt the Scheme system, after first requesting confirmation. 
  1433.       Any information that was in the environment is lost, so this should not 
  1434.       be done lightly. 
  1435.  
  1436.       The second procedure suspends Scheme; when this is done you may later 
  1437.       restart where you left off.  Unfortunately this is not possible in all 
  1438.       operating systems; currently it works under Unix versions that support 
  1439.       job control (i.e. all of the Unix versions for which we distribute 
  1440.       Scheme).  To suspend Scheme, evaluate 
  1441.  
  1442.             (quit)
  1443.  
  1444.       If your system supports suspension, this will cause Scheme to stop, and 
  1445.       you will be returned to the operating system's command interpreter. 
  1446.       Scheme remains stopped, and can be continued using the job-control 
  1447.       commands of your command interpreter.  If your system doesn't support 
  1448.       suspension, this procedure does nothing.  (Calling the quit procedure is 
  1449.       analogous to typing C-z, but it allows Scheme to respond by typing a 
  1450.       prompt when it is unsuspended.) 
  1451.  
  1452.      Several Edwin commands that you can execute.  These commands include 
  1453.       save-buffers-kill-scheme, normally bound to C-x C-c, and suspend-scheme, 
  1454.       normally bound to C-x C-z.  These two commands correspond to the 
  1455.       procedures exit and quit, respectively. 
  1456.  
  1457.      Graphical-interface buttons that you can activate.  Under OS/2 and 
  1458.       Windows, closing the console window (Scheme's main window) causes Scheme 
  1459.       to be terminated.  Under any operating system, closing an Edwin window 
  1460.       causes that window to go away, and if it is the only Edwin window, it 
  1461.       terminates Scheme as well. 
  1462.  
  1463.       Under OS/2, there are two distinct ways to close the console window. The 
  1464.       first is to use any of the usual window-closing methods, such as the 
  1465.       `Close' system-menu item or double-clicking on the system-menu icon. 
  1466.       When this is done, you will be presented with a dialog that gives you the 
  1467.       option to close the window with or without termating Scheme. The second 
  1468.       way is to select the `Exit' item from the `File' menu, which terminates 
  1469.       Scheme immediately with no dialog. 
  1470.  
  1471.  
  1472. ΓòÉΓòÉΓòÉ 6. Using Scheme ΓòÉΓòÉΓòÉ
  1473.  
  1474. This chapter describes how to use Scheme to evaluate expressions and load 
  1475. programs.  It also describes how to save custom "world images", and how to 
  1476. control the garbage collector.  Subsequent chapters will describe how to use 
  1477. the compiler, and how to debug your programs. 
  1478.  
  1479.  
  1480. ΓòÉΓòÉΓòÉ 6.1. The Read-Eval-Print Loop ΓòÉΓòÉΓòÉ
  1481.  
  1482. When you first start up Scheme from the command line (i.e. not under Edwin), 
  1483. you will be typing at a program called the Read-Eval-Print Loop (abbreviated 
  1484. REPL).  It displays a prompt at the left hand side of the screen whenever it is 
  1485. waiting for input.  You then type an expression (terminating it with RET). 
  1486. Scheme evaluates the expression, prints the result, and gives you another 
  1487. prompt. 
  1488.  
  1489.  
  1490. ΓòÉΓòÉΓòÉ 6.1.1. The Prompt and Level Number ΓòÉΓòÉΓòÉ
  1491.  
  1492. The repl prompt normally has the form 
  1493.  
  1494. 1 ]=>
  1495.  
  1496. The `1' in the prompt is a level number, which is always a positive integer. 
  1497. This number is incremented under certain circumstances, the most common being 
  1498. an error.  For example, here is what you will see if you type f o o RET after 
  1499. starting Scheme: 
  1500.  
  1501. ;Unbound variable: foo
  1502. ;To continue, call RESTART with an option number:
  1503. ; (RESTART 3) => Specify a value to use instead of foo.
  1504. ; (RESTART 2) => Define foo to a given value.
  1505. ; (RESTART 1) => Return to read-eval-print level 1.
  1506.  
  1507. 2 error>
  1508.  
  1509. In this case, the level number has been incremented to `2', which indicates 
  1510. that a new repl has been started (also the prompt string has been changed to 
  1511. remind you that the repl was started because of an error).  The `2' means that 
  1512. this new repl is "over" the old one.  The original repl still exists, and is 
  1513. waiting for you to return to it, for example, by entering (restart 1). 
  1514. Furthermore, if an error occurs while you are in this repl, yet another repl 
  1515. will be started, and the level number will be increased to `3'.  This can 
  1516. continue ad infinitum, but normally it is rare to use more than a few levels. 
  1517.  
  1518. The normal way to get out of an error repl and back to the top level repl is to 
  1519. use the C-g interrupt.  This is a single-keystroke command executed by holding 
  1520. down the CTRL key and pressing the G key.  C-g always terminates whatever is 
  1521. running and returns you to the top level repl immediately. 
  1522.  
  1523. Note: The appearance of the `error>' prompt does not mean that Scheme is in 
  1524. some weird inconsistent state that you should avoid.  It is merely a reminder 
  1525. that your program was in error: an illegal operation was attempted, but it was 
  1526. detected and avoided.  Often the best way to find out what is in error is to do 
  1527. some poking around in the error repl.  If you abort out of it, the context of 
  1528. the error will be destroyed, and you may not be able to find out what happened. 
  1529.  
  1530.  
  1531. ΓòÉΓòÉΓòÉ 6.1.2. Interrupting ΓòÉΓòÉΓòÉ
  1532.  
  1533. Scheme has several interrupt keys, which vary depending on the underlying 
  1534. operating system: under Unix, C-g and C-c; under Windows, C-b, C-x, C-u, C-g 
  1535. and C-c; under OS/2, C-b, C-x, C-u and C-g.  The C-g key stops any Scheme 
  1536. evaluation that is running and returns you to the top level repl.  C-c prompts 
  1537. you for another character and performs some action based on that character.  It 
  1538. is not necessary to type RET after C-g or C-c, nor is it needed after the 
  1539. character that C-c will ask you for. 
  1540.  
  1541. Here are the definitions of the more common interrupt keys; on systems that 
  1542. support C-c, type C-c ? for more possibilities.  Note that in any given 
  1543. implementation, only a subset of the following keys is available. 
  1544.  
  1545.  C-c C-c 
  1546.  C-g 
  1547.            Abort whatever Scheme evaluation is currently running and return to 
  1548.            the top-level repl.  If no evaluation is running, this is equivalent 
  1549.            to evaluating 
  1550.  
  1551.                       (cmdl-interrupt/abort-top-level)
  1552.  
  1553.  C-c C-x 
  1554.  C-x 
  1555.            Abort whatever Scheme evaluation is currently running and return to 
  1556.            the "current" repl.  If no evaluation is running, this is equivalent 
  1557.            to evaluating 
  1558.  
  1559.                       (cmdl-interrupt/abort-nearest)
  1560.  
  1561.  C-c C-u 
  1562.  C-u 
  1563.            Abort whatever Scheme evaluation is running and go up one level.  If 
  1564.            you are already at level number 1, the evaluation is aborted, 
  1565.            leaving you at level 1.  If no evaluation is running, this is 
  1566.            equivalent to evaluating 
  1567.  
  1568.                       (cmdl-interrupt/abort-previous)
  1569.  
  1570.  C-c C-b 
  1571.  C-b 
  1572.            Suspend whatever Scheme evaluation is running and start a breakpoint 
  1573.            repl.  The evaluation can be resumed by evaluating 
  1574.  
  1575.                       (continue)
  1576.  
  1577.            in that repl at any time. 
  1578.  
  1579.  C-c q 
  1580.            Similar to typing (exit) at the repl, except that it works even if 
  1581.            Scheme is running an evaluation, and does not request confirmation. 
  1582.  
  1583.  C-c z 
  1584.            Similar to typing (quit) at the repl, except that it works even if 
  1585.            Scheme is running an evaluation. 
  1586.  
  1587.  C-c i 
  1588.            Ignore the interrupt.  Type this if you made a mistake and didn't 
  1589.            really mean to type C-c. 
  1590.  
  1591.  C-c ? 
  1592.            Print help information.  This will describe any other options not 
  1593.            documented here. 
  1594.  
  1595.  
  1596. ΓòÉΓòÉΓòÉ 6.1.3. Restarting ΓòÉΓòÉΓòÉ
  1597.  
  1598. Another way to exit a repl is to use the restart procedure: 
  1599.  
  1600. -- procedure+: restart [k] 
  1601. This procedure selects and invokes a restart method.  The list of restart 
  1602. methods is different for each repl; in the case of an error repl, this list is 
  1603. printed when the repl is started: 
  1604.  
  1605. ;Unbound variable: foo
  1606. ;To continue, call RESTART with an option number:
  1607. ; (RESTART 3) => Specify a value to use instead of foo.
  1608. ; (RESTART 2) => Define foo to a given value.
  1609. ; (RESTART 1) => Return to read-eval-print level 1.
  1610.  
  1611. 2 error>
  1612.  
  1613. If the k argument is given, it must be a positive integer index into the list 
  1614. (in the example it must be between one and three inclusive).  The integer k 
  1615. selects an item from the list and invokes it.  If k is not given, restart 
  1616. prints the list and prompts for the integer index: 
  1617.  
  1618. 2 error> (restart)
  1619. ;Choose an option by number:
  1620. ;  3: Specify a value to use instead of foo.
  1621. ;  2: Define foo to a given value.
  1622. ;  1: Return to read-eval-print level 1.
  1623.  
  1624. Option number:
  1625.  
  1626. The simplest restart methods just perform their actions.  For example: 
  1627.  
  1628. 2 error> (restart 1)
  1629. ;Abort!
  1630.  
  1631. 1 ]=>
  1632.  
  1633. Other methods will prompt for more input before continuing: 
  1634.  
  1635. 2 error> (restart)
  1636. ;Choose an option by number:
  1637. ;  3: Specify a value to use instead of foo.
  1638. ;  2: Define foo to a given value.
  1639. ;  1: Return to read-eval-print level 1.
  1640.  
  1641. Option number: 3
  1642.  
  1643. Value to use instead of foo: '(a b)
  1644. ;Value: (a b)
  1645.  
  1646. 1 ]=>
  1647.  
  1648.  
  1649. ΓòÉΓòÉΓòÉ 6.1.4. The Current REPL Environment ΓòÉΓòÉΓòÉ
  1650.  
  1651. Every repl has a current environment, which is the place where expressions are 
  1652. evaluated and definitions are stored.  When Scheme is started, this environment 
  1653. is the value of the variable user-initial-environment.  There are a number of 
  1654. other environments in the system, for example system-global-environment, where 
  1655. the runtime system's bindings are stored. 
  1656.  
  1657. You can get the current repl environment by evaluating 
  1658.  
  1659. (nearest-repl/environment)
  1660.  
  1661. There are several other ways to obtain environments.  For example, if you have 
  1662. a procedure object, you can get a pointer to the environment in which it was 
  1663. closed by evaluating 
  1664.  
  1665. (procedure-environment procedure)
  1666.  
  1667. Your programs create new environments whenever a procedure is called. 
  1668.  
  1669. Here is the procedure that changes the repl's environment: 
  1670.  
  1671. -- procedure+: ge environment 
  1672. Changes the current repl environment to be environment (ge stands for "Goto 
  1673. Environment").  Environment is allowed to be a procedure as well as an 
  1674. environment object.  If it is a procedure, then the closing environment of that 
  1675. procedure is used in its place. 
  1676.  
  1677. -- procedure+: pe 
  1678. This procedure is useful for finding out which environment you are in (pe 
  1679. stands for "Print Environment").  If the current repl environment belongs to a 
  1680. package, then pe returns the package name (a list of symbols).  If the current 
  1681. repl environment does not belong to a package then the environment is returned. 
  1682.  
  1683. -- procedure+: gst syntax-table 
  1684. In addition to the current environment, each repl maintains a current syntax 
  1685. table.  The current syntax table tells the repl which keywords are used to 
  1686. identify special forms (e.g. if, lambda).  If you write macros, you may want to 
  1687. make your own syntax table, in which case it is useful to be able to make that 
  1688. syntax table be the current one; gst allows you to do that. 
  1689.  
  1690.  
  1691. ΓòÉΓòÉΓòÉ 6.2. Loading Files ΓòÉΓòÉΓòÉ
  1692.  
  1693. To load files of Scheme code, use the procedure load: 
  1694.  
  1695. -- procedure: load filename [environment [syntax-table [purify?]]] 
  1696. Filename may be a string naming a file, or a list of strings naming multiple 
  1697. files.  Environment, if given, is the environment to evaluate the file in; if 
  1698. not given the current repl environment is used.  Likewise syntax-table is the 
  1699. syntax table to use. 
  1700.  
  1701. The optional argument purify? is a boolean that says whether to move the 
  1702. contents of the file into constant space after it is loaded but before it is 
  1703. evaluated.  This is performed by calling the procedure purify (see Garbage 
  1704. Collection).  If purify? is given and true, this is done; otherwise it is not. 
  1705.  
  1706. load determines whether the file to be loaded is binary or source code, and 
  1707. performs the appropriate action.  By convention, files of source code have a 
  1708. pathname type of "scm", and files of binary SCode have pathname type "bin". 
  1709. Native-code binaries have pathname type "com".  (See the description of 
  1710. pathname-type in the reference manual.) 
  1711.  
  1712. -- variable+: load-noisily? 
  1713. If load-noisily? is set to #t, load will print the value of each expression in 
  1714. the file as it is evaluated.  Otherwise, nothing is printed except for the 
  1715. value of the last expression in the file.  (Note: the noisy loading feature is 
  1716. implemented for source-code files only.) 
  1717.  
  1718. -- variable+: load/default-types 
  1719. When load is given a pathname without a type, it uses the value of this 
  1720. variable to determine what pathname types to look for and how to load the file. 
  1721. load/default-types is a list of associations that maps pathname types (strings) 
  1722. to loader procedures.  load tries the pathname types in the order that they 
  1723. appear in the list.  The initial value of this variable has pathname types in 
  1724. this order: 
  1725.  
  1726. "com" "so" "sl" "bin" "scm"
  1727.  
  1728. This means that, for example, (load "foo") will try to load `foo.com' first, 
  1729. and `foo.scm' only after looking for and failing to find the other pathname 
  1730. types. 
  1731.  
  1732. All pathnames are interpreted relative to a working directory, which is 
  1733. initialized when Scheme is started.  The working directory can be obtained by 
  1734. calling the procedure pwd or modified by calling the procedure cd; see the 
  1735. reference manual for details.  Files may be loaded when Scheme first starts; 
  1736. see the `-load' command-line option for details. 
  1737.  
  1738. -- procedure+: load-option symbol [no-error?] 
  1739. Loads the option specified by symbol; if already loaded, does nothing.  Returns 
  1740. symbol; if there is no such option, an error is signalled.  However, if 
  1741. no-error? is specified and true, no error is signalled in this case, and #f is 
  1742. returned. 
  1743.  
  1744. A number of built-in options are defined: 
  1745.  
  1746.  compress 
  1747.            Code to compress and uncompress files.  Undocumented.  Used by the 
  1748.            runtime system for compression of compiled-code debugging 
  1749.            information. 
  1750.  
  1751.  format 
  1752.            The format procedure.  Documented in the Reference Manual. 
  1753.  
  1754.  hash-table 
  1755.            The hash-table data type.  Documented in the Reference Manual. 
  1756.  
  1757.  ordered-vector 
  1758.            Code to search and do completion on vectors of ordered elements. 
  1759.            Undocumented. 
  1760.  
  1761.  rb-tree 
  1762.            The red-black tree data type.  Documented in the Reference Manual. 
  1763.  
  1764.  stepper 
  1765.            Code to step through the evaluation of Scheme expressions. 
  1766.            Undocumented.  Used by the Edwin command M-x step-expression. 
  1767.  
  1768.  subprocess 
  1769.            Code to run other programs as subprocesses of the Scheme process; 
  1770.            implemented under Unix and OS/2 only.  Undocumented, but used 
  1771.            extensively by Edwin. 
  1772.  
  1773.  wt-tree 
  1774.            The weight-balanced tree data type.  Documented in the Reference 
  1775.            Manual. 
  1776.  
  1777.  In addition to the built-in options, you may define other options to be loaded 
  1778.  by load-options by modifying the file `optiondb.scm' on the library path.  An 
  1779.  example file is included with the distribution; normally this file consists of 
  1780.  a series of calls to the procedure define-load-option, terminated by the 
  1781.  expression 
  1782.  
  1783.   (further-load-options standard-load-options)
  1784.  
  1785.  -- procedure+: define-load-option symbol thunk ... 
  1786.  Each thunk must be a procedure of no arguments.  Defines the load option named 
  1787.  symbol.  When the procedure load-option is called with symbol as an argument, 
  1788.  the thunk arguments are executed in order from left to right. 
  1789.  
  1790.  
  1791. ΓòÉΓòÉΓòÉ 6.3. World Images ΓòÉΓòÉΓòÉ
  1792.  
  1793. A world image, also called a band, is a file that contains a complete Scheme 
  1794. system, perhaps additionally including user application code.  Scheme provides 
  1795. a method for saving and restoring world images. The method writes a file 
  1796. containing all of the Scheme code in the running process.  The file 
  1797. `runtime.com' that is loaded by the microcode is just such a band.  To make 
  1798. your own band, use the procedure disk-save. 
  1799.  
  1800. -- procedure+: disk-save filename [identify] 
  1801. Causes a band to be written to the file specified by filename. The optional 
  1802. argument identify controls what happens when that band is restored, as follows: 
  1803.  
  1804.  not specified 
  1805.            Start up in the top-level repl, identifying the world in the normal 
  1806.            way. 
  1807.  
  1808.  a string 
  1809.            Do the same thing except print that string instead of `Scheme' when 
  1810.            restarting. 
  1811.  
  1812.  the constant #t 
  1813.            Restart exactly where you were when the call to disk-save was 
  1814.            performed.  This is especially useful for saving your state when an 
  1815.            error has occurred and you are not in the top-level repl. 
  1816.  
  1817.  the constant #f 
  1818.            Just like #t, except that the runtime system will not perform normal 
  1819.            restart initializations; in particular, it will not load your init 
  1820.            file. 
  1821.  
  1822.  To restore a saved band, give the `-band' option when starting Scheme. 
  1823.  Alternatively, evaluate (disk-restore filename), which will destroy the 
  1824.  current world, replacing it with the saved world. The argument to disk-restore 
  1825.  may be omitted, in which case it defaults to the filename from which the 
  1826.  current world was last restored. 
  1827.  
  1828.  Note: with the C back end, disk-save is not very useful.  The reason is that 
  1829.  compiled procedures are compiled C code that has been dynamically linked in, 
  1830.  and disk-save does not save any C procedures.  Your system is a C back end 
  1831.  system if the following expression does not evaluate to #f: 
  1832.  
  1833.   (system-library-directory-pathname "shared")
  1834.  
  1835.  Note: when restoring a saved band, the Scheme executable must be configured 
  1836.  with a large enough constant space and heap to hold the band's contents.  If 
  1837.  you attempt to restore a band using the `-band' option, and the band is too 
  1838.  large, Scheme will write an error message that tells you the appropriate 
  1839.  command-line options needed to load that band.  If you attempt restore a 
  1840.  too-large band using disk-restore, Scheme will signal an error, but will not 
  1841.  provide the configuration information.  In general, the configuration that was 
  1842.  used to save a band is sufficiently large to restore it. 
  1843.  
  1844.  
  1845. ΓòÉΓòÉΓòÉ 6.4. Garbage Collection ΓòÉΓòÉΓòÉ
  1846.  
  1847. This section describes procedures that control garbage collection. See Memory 
  1848. Usage, for a discussion of how MIT Scheme uses memory. 
  1849.  
  1850. -- procedure+: gc-flip [safety-margin] 
  1851. Forces a garbage collection to occur.  Returns the number of words of storage 
  1852. available after collection, an exact non-negative integer. 
  1853.  
  1854. Safety-margin determines the number of words of storage available for system 
  1855. tasks in-between detecting the need for a garbage collection and entering the 
  1856. garbage collector proper.  (An example of such a system task is changing the 
  1857. run-light to show "gc" when scheme is running under Emacs.)  Note well: you 
  1858. should not specify safety-margin unless you know what you are doing.  If you 
  1859. specify a value that is too small, you can put Scheme in an unusable state. 
  1860.  
  1861. -- procedure+: purify object [pure-space? [queue?]] 
  1862. Moves object from the heap into constant space.  Has no effect if object is 
  1863. already stored in constant space.  Object is moved in its entirety; if it is a 
  1864. compound object such as a list, a vector, or a record, then all of the objects 
  1865. that object points to are also moved to constant space. 
  1866.  
  1867. There are three important effects associated with moving an object to constant 
  1868. space.  The first and most important effect is that the object takes up half as 
  1869. much space, because when in the heap, the system must reserve space for the 
  1870. object in both the active heap and the inactive heap; if the object is in 
  1871. constant space it is not copied and therefore no extra space is required.  The 
  1872. second effect is that garbage collection will take less time, because object 
  1873. will no longer be copied.  The third effect is that the space allocated to 
  1874. object is permanently allocated, because constant space is never cleaned; any 
  1875. unreachable objects in constant space remain there until the Scheme process is 
  1876. terminated. 
  1877.  
  1878. The optional argument pure-space? is obsolete; it defaults to #t and when 
  1879. explicitly specified should always be #t. 
  1880.  
  1881. The optional argument queue? specifies whether object should be moved to 
  1882. constant space immediately, or should be queued to be moved during the next 
  1883. garbage collection.  This argument defaults to #t.  The reason for queuing 
  1884. these requests is that moving an object to constant space requires a garbage 
  1885. collection to occur, a relatively slow process.  By queuing the requests, this 
  1886. overhead is avoided, because moving an object during a garbage collection has 
  1887. no effect on the time of the garbage collection.  Furthermore, if several 
  1888. requests are queued, they can all be processed together in one garbage 
  1889. collection, while if done separately they would each require their own garbage 
  1890. collection. 
  1891.  
  1892. -- procedure+: flush-purification-queue! 
  1893. Forces any pending queued purification requests to be processed.  This examines 
  1894. the purify queue, and if it contains any requests, forces a garbage collection 
  1895. to process them.  If the queue is empty, does nothing. 
  1896.  
  1897. -- procedure+: print-gc-statistics 
  1898. Prints out information about memory allocation and the garbage collector.  The 
  1899. information is printed to the current output port. Shows how much space is "in 
  1900. use" and how much is "free", separately for the heap and constant space.  The 
  1901. amounts are shown in words, and also in 1024-word blocks; the block figures 
  1902. make it convenient to use these numbers to adjust the arguments given to the 
  1903. `-heap' and `-constant' command-line options.  Following the allocation 
  1904. figures, information about the most recent 8 garbage collections is shown, in 
  1905. the same format as a gc notification. 
  1906.  
  1907. Note that these numbers are accurate at the time that print-gc-statistics is 
  1908. called.  In the case of the heap, the "in use" figure shows how much memory has 
  1909. been used since the last garbage collection, and includes all live objects as 
  1910. well as any uncollected garbage that has accumulated since then.  The only 
  1911. accurate way to determine the size of live storage is to subtract the value of 
  1912. `(gc-flip)' from the size of the heap.  The size of the heap can be determined 
  1913. by adding the "in use" and "free" figures reported by print-gc-statistics. 
  1914.  
  1915. (print-gc-statistics)
  1916. constant in use:   534121 words =   521 blocks +  617 words
  1917. constant free:        128 words =     0 blocks +  128 words
  1918. heap in use:        34845 words =    34 blocks +   29 words
  1919. heap free:         205530 words =   200 blocks +  730 words
  1920. GC #1: took: 0.13 (81%) CPU time, 0.15 (1%) real time; free: 207210
  1921. ;No value
  1922.  
  1923. -- procedure+: set-gc-notification! [on?] 
  1924. Controls whether the user is notified of garbage collections.  If on? is given 
  1925. and #f, notification is enabled; otherwise notification is disabled.  By 
  1926. default, notification is disabled. 
  1927.  
  1928. The notification appears as a single line like the following, showing how many 
  1929. garbage collections have occurred, the time taken to perform the garbage 
  1930. collection and the free storage remaining (in words) after collection. 
  1931.  
  1932. GC #5: took: 0.50 (8%) CPU time, 0.70 (2%) real time; free: 364346
  1933.  
  1934. To operate comfortably, the amount of free storage after garbage collection 
  1935. should be a substantial proportion of the heap size.  If the percentage CPU 
  1936. time is consistently high (over 20%), you should consider running with a larger 
  1937. heap.  A rough rule of thumb to halve the gc overhead is to take the amount of 
  1938. free storage, divide by 1000, and add this figure to the current value used for 
  1939. the `-heap' command-line option.  Unfortunately there is no way to adjust the 
  1940. heap size without restarting Scheme. 
  1941.  
  1942. -- procedure+: toggle-gc-notification! 
  1943. Toggles gc notification on and off.  If gc notification is turned on, turns it 
  1944. off; otherwise turns it on. 
  1945.  
  1946.  
  1947. ΓòÉΓòÉΓòÉ 7. Compiling Programs ΓòÉΓòÉΓòÉ
  1948.  
  1949. Note: the procedures described in this section are only available when the 
  1950. compiler is loaded, as in the `compiler.com' world image. Furthermore, cf is 
  1951. only available on machines that support native-code compilation. 
  1952.  
  1953.  
  1954. ΓòÉΓòÉΓòÉ 7.1. Compilation Procedures ΓòÉΓòÉΓòÉ
  1955.  
  1956. -- procedure+: cf filename [destination] 
  1957. This is the program that transforms a source-code file into native-code binary 
  1958. form.  If destination is not given, as in 
  1959.  
  1960. (cf "foo")
  1961.  
  1962. cf compiles the file `foo.scm', producing the file `foo.com' (incidentally it 
  1963. will also produce `foo.bin', `foo.bci', and possibly `foo.ext').  If you later 
  1964. evaluate 
  1965.  
  1966. (load "foo")
  1967.  
  1968. `foo.com' will be loaded rather than `foo.scm'. 
  1969.  
  1970. If destination is given, it says where the output files should go. If this 
  1971. argument is a directory, they go in that directory, e.g.: 
  1972.  
  1973. (cf "foo" "../bar/")
  1974.  
  1975. will take `foo.scm' and generate the file `../bar/foo.com'. If destination is 
  1976. not a directory, it is the root name of the output: 
  1977.  
  1978. (cf "foo" "bar")
  1979.  
  1980. takes `foo.scm' and generates `bar.com'. 
  1981.  
  1982. About the `.bci' files: these files contain the debugging information that 
  1983. Scheme uses when you call debug to examine compiled code.  When you load a 
  1984. `.com' file, Scheme remembers where it was loaded from, and when the debugger 
  1985. (or pp) looks at the compiled code from that file, it attempts to find the 
  1986. `.bci' file in the same directory from which the `.com' file was loaded.  Thus 
  1987. it is a good idea to leave these files together. 
  1988.  
  1989. `.bci' files are stored in a compressed format. The debugger has to uncompress 
  1990. the files when it looks at them, and on a slow machine this can take a 
  1991. noticeable time. The system takes steps to reduce the impact of this behaviour: 
  1992. debugging information is cached in memory, and uncompressed versions of `.bci' 
  1993. files are kept around. The default behavior is that a temporary file is created 
  1994. and the `.bci' file is uncompressed into it.  The temporary file is kept around 
  1995. for a while afterwards, and during that time if the uncompressed `.bci' file is 
  1996. needed the temporary file is used.  Each such reference updates an `access 
  1997. time' that is associated with the temporary file.  The garbage collector checks 
  1998. the access times of all such temporary files, and deletes any that have not 
  1999. been accessed in five minutes or more.  All of the temporaries are deleted 
  2000. automatically when the Scheme process is killed. 
  2001.  
  2002. Two other behaviors are available.  One of them uncompresses the `.bci' file 
  2003. each time it is referenced, and the other uncompresses the `.bci' file and 
  2004. writes it back out as a `.bif' file. The `.bif' file remains after Scheme 
  2005. exits. The time interval and the behavior are controlled by variables. 
  2006.  
  2007. -- variable+: *save-uncompressed-files?* 
  2008. This variable affects what happens when `.bci' files are uncompressed.  It 
  2009. allows a trade-off between performance and disk space. There are three possible 
  2010. values: 
  2011.  
  2012.  #f 
  2013.            The uncompressed versions of `.bci' files are never saved.  Each 
  2014.            time the information is needed the `.bci' file is uncompressed. This 
  2015.            option requires the minimum amount of disk space and is the slowest. 
  2016.  
  2017.  automatic 
  2018.            Uncompressed versions of `.bci' files are kept as temporary files. 
  2019.            The temporary files are deleted when Scheme exits, and if they have 
  2020.            not been used for a while.  This is the default. 
  2021.  
  2022.  #t 
  2023.            The `.bci' files are uncompressed to permanent `.bif' files. These 
  2024.            files remain on disk after Scheme exits, and are rather large - 
  2025.            about twice the size of the corresponding `.bci' files.  If you 
  2026.            choose this option and you are running out of disk space you may 
  2027.            delete the `.bif' files.  They will be regenerated as needed. 
  2028.  
  2029.  -- variable+: *uncompressed-file-lifetime* 
  2030.  The minimum length of time that a temporary uncompressed version of a `.bci' 
  2031.  file will stay on disk after it is last used. The time is in milliseconds; the 
  2032.  default is ` 300000' (five minutes). 
  2033.  
  2034.  -- variable+: load-debugging-info-on-demand? 
  2035.  If this variable is `#f', then printing a compiled procedure will print the 
  2036.  procedure's name only if the debugging information for that procedure is 
  2037.  already loaded.  Otherwise, it will force loading of the debugging 
  2038.  information. The default value is #f. 
  2039.  
  2040.  -- procedure+: sf filename [destination] 
  2041.  sf is the program that transforms a source-code file into binary SCode form; 
  2042.  it is used on machines that do not support native-code compilation.  It 
  2043.  performs numerous optimizations that can make your programs run considerably 
  2044.  faster than unoptimized interpreted code. Also, the binary files that it 
  2045.  generates load very quickly compared to source-code files. 
  2046.  
  2047.  The simplest way to use sf is just to say: 
  2048.  
  2049.   (sf filename)
  2050.  
  2051.  This will cause your file to be transformed, and the resulting binary file to 
  2052.  be written out with the same name, but with pathname type "bin".  If you do 
  2053.  not specify a pathname type on the input file, "scm" is assumed. 
  2054.  
  2055.  Like load, the first argument to sf may be a list of filenames rather than a 
  2056.  single filename. 
  2057.  
  2058.  sf takes an optional second argument, which is the filename of the output 
  2059.  file.  If this argument is a directory, then the output file has its normal 
  2060.  name but is put in that directory instead. 
  2061.  
  2062.  
  2063. ΓòÉΓòÉΓòÉ 7.2. Declarations ΓòÉΓòÉΓòÉ
  2064.  
  2065. Several declarations can be added to your programs to help cf and sf make them 
  2066. more efficient. 
  2067.  
  2068.  
  2069. ΓòÉΓòÉΓòÉ 7.2.1. Standard Names ΓòÉΓòÉΓòÉ
  2070.  
  2071. Normally, all files have a line 
  2072.  
  2073. (declare (usual-integrations))
  2074.  
  2075. near their beginning, which tells the compiler that free variables whose names 
  2076. are defined in system-global-environment will not be shadowed by other 
  2077. definitions when the program is loaded.  If you redefine some global name in 
  2078. your code, for example car, cdr, and cons, you should indicate it in the 
  2079. declaration: 
  2080.  
  2081. (declare (usual-integrations car cdr cons))
  2082.  
  2083. You can obtain an alphabetically-sorted list of the names that the 
  2084. usual-integrations declaration affects by evaluating the following expression: 
  2085.  
  2086. (eval '(sort (append usual-integrations/constant-names
  2087.                      usual-integrations/expansion-names)
  2088.              (lambda (x y)
  2089.                (string<=? (symbol->string x)
  2090.                           (symbol->string y))))
  2091.       (->environment '(scode-optimizer)))
  2092.  
  2093.  
  2094. ΓòÉΓòÉΓòÉ 7.2.2. In-line Coding ΓòÉΓòÉΓòÉ
  2095.  
  2096. Another useful facility is the ability to in-line code procedure definitions. 
  2097. In fact, the compiler will perform full beta conversion, with automatic 
  2098. renaming, if you request it.  Here are the relevant declarations: 
  2099.  
  2100. -- declaration+: integrate name ... 
  2101. The variables names must be defined in the same file as this declaration.  Any 
  2102. reference to one of the named variables that appears in the same block as the 
  2103. declaration, or one of its descendant blocks, will be replaced by the 
  2104. corresponding binding's value expression. 
  2105.  
  2106. -- declaration+: integrate-operator name ... 
  2107. Similar to the integrate declaration, except that it only substitutes for 
  2108. references that appear in the operator position of a combination.  All other 
  2109. references are ignored. 
  2110.  
  2111. -- declaration+: integrate-external filename 
  2112. Causes the compiler to use the top-level integrations provided by filename. 
  2113. filename should not specify a file type, and the source-code file that it names 
  2114. must have been previously processed by the compiler. 
  2115.  
  2116. If filename is a relative filename (the normal case), it is interpreted as 
  2117. being relative to the file in which the declaration appears.  Thus if the 
  2118. declaration appears in file `/usr/cph/foo.scm', then the compiler looks for a 
  2119. file called `/usr/cph/filename.ext'. 
  2120.  
  2121. Note: When the compiler finds top-level integrations, it collects them and 
  2122. outputs them into an auxiliary file with extension `.ext'. This `.ext' file is 
  2123. what the integrate-external declaration refers to. 
  2124.  
  2125. Note that the most common use of this facility, in-line coding of procedure 
  2126. definitions, requires a somewhat complicated use of these declarations. 
  2127. Because this is so common, there is a special form, define-integrable, which is 
  2128. like define but performs the appropriate declarations.  For example: 
  2129.  
  2130. (define-integrable (foo-bar foo bar)
  2131.   (vector-ref (vector-ref foo bar) 3))
  2132.  
  2133. Here is how you do the same thing without this special form: there should be an 
  2134. integrate-operator declaration for the procedure's name, and (internal to the 
  2135. procedure's definition) an integrate declaration for each of the procedure's 
  2136. parameters, like this: 
  2137.  
  2138. (declare (integrate-operator foo-bar))
  2139.  
  2140. (define foo-bar
  2141.   (lambda (foo bar)
  2142.     (declare (integrate foo bar))
  2143.     (vector-ref (vector-ref foo bar) 3)))
  2144.  
  2145. The reason for this complication is as follows: the integrate-operator 
  2146. declaration finds all the references to foo-bar and replaces them with the 
  2147. lambda expression from the definition.  Then, the integrate declarations take 
  2148. effect because the combination in which the reference to foo-bar occurred 
  2149. supplies code that is substituted throughout the body of the procedure 
  2150. definition.  For example: 
  2151.  
  2152. (foo-bar (car baz) (cdr baz))
  2153.  
  2154. First use the integrate-operator declaration: 
  2155.  
  2156. ((lambda (foo bar)
  2157.    (declare (integrate foo bar))
  2158.    (vector-ref (vector-ref foo bar) 3))
  2159.  (car baz)
  2160.  (cdr baz))
  2161.  
  2162. Next use the internal integrate declaration: 
  2163.  
  2164. ((lambda (foo bar)
  2165.    (vector-ref (vector-ref (car baz) (cdr baz)) 3))
  2166.  (car baz)
  2167.  (cdr baz))
  2168.  
  2169. Next notice that the variables foo and bar are not used, and eliminate them: 
  2170.  
  2171. ((lambda ()
  2172.    (vector-ref (vector-ref (car baz) (cdr baz)) 3)))
  2173.  
  2174. Finally, remove the ((lambda () ...)) to produce 
  2175.  
  2176. (vector-ref (vector-ref (car baz) (cdr baz)) 3)
  2177.  
  2178.  
  2179. ΓòÉΓòÉΓòÉ 7.2.2.1. Useful tip ΓòÉΓòÉΓòÉ
  2180.  
  2181. To see the effect of integration declarations (and of macros) on a source file, 
  2182. pretty-print the `.bin' file like this (be prepared for a lot of output). 
  2183.  
  2184. (sf "foo.scm")
  2185. (pp (fasload "foo.bin"))
  2186.  
  2187.  
  2188. ΓòÉΓòÉΓòÉ 7.2.3. Operator Replacement ΓòÉΓòÉΓòÉ
  2189.  
  2190. The replace-operator declaration is provided to inform the compiler that 
  2191. certain operators may be replaced by other operators depending on the number of 
  2192. arguments. For example: 
  2193.  
  2194. Declaration: 
  2195.  
  2196. (declare (replace-operator (map (2 map-2) (3 map-3))))
  2197.  
  2198. Replacements: 
  2199.  
  2200. (map f x y z) -> (map f x y z)
  2201. (map f x y) -> (map-3 f x y)
  2202. (map f x) -> (map-2 f x)
  2203. (map f) -> (map f)
  2204. (map) -> (map)
  2205.  
  2206. Presumably map-2 and map-3 are efficient versions of map that are written for 
  2207. exactly two and three arguments respectively.  All the other cases are not 
  2208. expanded but are handled by the original, general map procedure, which is less 
  2209. efficient because it must handle a variable number of arguments. 
  2210.  
  2211. -- declaration+: replace-operator name ... 
  2212.  
  2213. The syntax of this declaration is 
  2214.  
  2215. (replace-operator
  2216.   (name
  2217.     (nargs1 value1)
  2218.     (nargs2 value2)
  2219.     ...))
  2220.  
  2221. where 
  2222.  
  2223.      name is a symbol. 
  2224.  
  2225.      nargs1, nargs2 etc. are non-negative integers, or one of the following 
  2226.       symbols:  any, else or otherwise. 
  2227.  
  2228.      value1, value2 etc. are simple expressions in one of these forms: 
  2229.  
  2230.       'constant 
  2231.                      A constant. 
  2232.  
  2233.       variable 
  2234.                      A variable. 
  2235.  
  2236.       (primitive primitive-name [arity]) 
  2237.                      The primitive procedure named primitive-name.  The 
  2238.                      optional element arity, a non-negative integer, specifies 
  2239.                      the number of arguments that the primitive accepts. 
  2240.  
  2241.       (global var) 
  2242.                      A global variable. 
  2243.  
  2244.  The meanings of these fields are: 
  2245.  
  2246.      name is the name of the operator to be reduced.  If is is not shadowed 
  2247.       (for example, by a let) then it may be replaced according to the 
  2248.       following rules. 
  2249.  
  2250.      If the operator has nargsN arguments then it is replaced with a call to 
  2251.       valueN with the same arguments. 
  2252.  
  2253.      If the number of arguments is not listed, and one of the nargsN is any, 
  2254.       else or otherwise, then the operation is replaced with a call to the 
  2255.       corresponding valueN. Only one of the nargsN may be of this form. 
  2256.  
  2257.      If the number of arguments is not listed and none of the nargsN is any, 
  2258.       else or otherwise, then the operation is not replaced. 
  2259.  
  2260.  
  2261. ΓòÉΓòÉΓòÉ 7.2.4. Operator Reduction ΓòÉΓòÉΓòÉ
  2262.  
  2263. The reduce-operator declaration is provided to inform the compiler that certain 
  2264. names are n-ary versions of binary operators. Here are some examples: 
  2265.  
  2266. Declaration: 
  2267.  
  2268. (declare (reduce-operator (cons* cons)))
  2269.  
  2270. Replacements: 
  2271.  
  2272. (cons* x y z w) -> (cons x (cons y (cons z w))),
  2273. (cons* x y) -> (cons x y)
  2274. (cons* x) -> x
  2275. (cons*) error--> too few arguments
  2276.  
  2277. Declaration: 
  2278.  
  2279. (declare (reduce-operator (list cons (null-value '() any))))
  2280.  
  2281. Replacements: 
  2282.  
  2283. (list x y z w) -> (cons x (cons y (cons z (cons w '()))))
  2284. (list x y) -> (cons x (cons y '()))
  2285. (list x) -> (cons x '())
  2286. (list) -> '()
  2287.  
  2288. Declaration: 
  2289.  
  2290. (declare (reduce-operator (- %- (null-value 0 single) (group left))))
  2291.  
  2292. Replacements: 
  2293.  
  2294. (- x y z w) -> (%- (%- (%- x y) z) w)
  2295. (- x y) -> (%- x y)
  2296. (- x) -> (%- 0 x)
  2297. (-) -> 0
  2298.  
  2299. Declaration: 
  2300.  
  2301. (declare (reduce-operator (+ %+ (null-value 0 none) (group right))))
  2302.  
  2303. Replacements: 
  2304.  
  2305. (+ x y z w) -> (%+ x (%+ y (%+ z w)))
  2306. (+ x y) -> (%+ x y)
  2307. (+ x) -> x
  2308. (+) -> 0
  2309.  
  2310. Note: This declaration does not cause an appropriate definition of %+ (in the 
  2311. last example) to appear in your code.  It merely informs the compiler that 
  2312. certain optimizations can be performed on calls to + by replacing them with 
  2313. calls to %+.  You should provide a definition of %+ as well, although it is not 
  2314. required. 
  2315.  
  2316. Declaration: 
  2317.  
  2318. (declare (reduce-operator (apply (primitive cons)
  2319.                                  (group right)
  2320.                                  (wrapper (global apply) 1))))
  2321.  
  2322. Replacements: 
  2323.  
  2324. (apply f x y z w) -> ((access apply ()) f (cons x (cons y (cons z w))))
  2325. (apply f x y) -> ((access apply ()) f (cons x y))
  2326. (apply f x) -> (apply f x)
  2327. (apply f) -> (apply f)
  2328. (apply) -> (apply)
  2329.  
  2330. -- declaration+: reduce-operator name ... 
  2331. The general format of the declaration is (brackets denote optional elements): 
  2332.  
  2333. (reduce-operator
  2334.   (name
  2335.     binop
  2336.     [(group ordering)]
  2337.     [(null-value value null-option)]
  2338.     [(singleton unop)]
  2339.     [(wrapper wrap [n])]
  2340.     [(maximum m)]
  2341.   ))
  2342.  
  2343. where 
  2344.  
  2345.      n and m are non-negative integers. 
  2346.  
  2347.      name is a symbol. 
  2348.  
  2349.      binop, value, unop, and wrap are simple expressions in one of these 
  2350.       forms: 
  2351.  
  2352.       'constant 
  2353.                      A constant. 
  2354.  
  2355.       variable 
  2356.                      A variable. 
  2357.  
  2358.       (primitive primitive-name [arity]) 
  2359.                      The primitive procedure named primitive-name.  The 
  2360.                      optional element arity specifies the number of arguments 
  2361.                      that the primitive accepts. 
  2362.  
  2363.       (global var) 
  2364.                      A global variable. 
  2365.  
  2366.      null-option is either always, any, one, single, none, or empty. 
  2367.  
  2368.      ordering is either left, right, or associative. 
  2369.  
  2370.  The meaning of these fields is: 
  2371.  
  2372.      name is the name of the n-ary operation to be reduced. 
  2373.  
  2374.      binop is the binary operation into which the n-ary operation is to be 
  2375.       reduced. 
  2376.  
  2377.      The group option specifies whether name associates to the right or left. 
  2378.  
  2379.      The null-value option specifies a value to use in the following cases: 
  2380.  
  2381.       none 
  2382.       empty 
  2383.                      When no arguments are supplied to name, value is returned. 
  2384.  
  2385.       one 
  2386.       single 
  2387.                      When a single argument is provided to name, value becomes 
  2388.                      the second argument to binop. 
  2389.  
  2390.       any 
  2391.       always 
  2392.                      binop is used on the "last" argument, and value provides 
  2393.                      the remaining argument to binop. 
  2394.  
  2395.       In the above options, when value is supplied to binop, it is supplied on 
  2396.       the left if grouping to the left, otherwise it is supplied on the right. 
  2397.  
  2398.      The singleton option specifies a function, unop, to be invoked on the 
  2399.       single argument left.  This option supersedes the null-value option, 
  2400.       which can only take the value none. 
  2401.  
  2402.      The wrapper option specifies a function, wrap, to be invoked on the 
  2403.       result of the outermost call to binop after the expansion. If n is 
  2404.       provided it must be a non-negative integer indicating a number of 
  2405.       arguments that are transferred verbatim from the original call to the 
  2406.       wrapper.  They are passed to the left of the reduction. 
  2407.  
  2408.      The maximum option specifies that calls with more than m arguments should 
  2409.       not be reduced. 
  2410.  
  2411.  
  2412. ΓòÉΓòÉΓòÉ 7.3. Efficiency Tips ΓòÉΓòÉΓòÉ
  2413.  
  2414. How you write your programs can have a large impact on how efficiently the 
  2415. compiled program runs.  The most important thing to do, after choosing suitable 
  2416. data structures, is to put the following declaration near the beginning of the 
  2417. file. 
  2418.  
  2419. (declare (usual-integrations))
  2420.  
  2421. Without this declaration the compiler cannot recognize any of the common 
  2422. operators and compile them efficiently. 
  2423.  
  2424. The usual-integrations declaration is usually sufficient to get good quality 
  2425. compiled code. 
  2426.  
  2427. If you really need to squeeze more performance out of you code then we hope 
  2428. that you find the following grab-bag of tips, hints and explanations useful. 
  2429.  
  2430.  
  2431. ΓòÉΓòÉΓòÉ 7.3.1. Coding style ΓòÉΓòÉΓòÉ
  2432.  
  2433.  
  2434. ΓòÉΓòÉΓòÉ 7.3.1.1. Better predicates ΓòÉΓòÉΓòÉ
  2435.  
  2436. Consider the following implementation of map as might be found in any 
  2437. introductory book on Scheme: 
  2438.  
  2439. (define (map f lst)
  2440.   (if (null? lst)
  2441.       '()
  2442.       (cons (f (car lst)) (map f (cdr lst)))))
  2443.  
  2444. The problem with this definition is that at the points where car and cdr are 
  2445. called we still do not know that lst is a pair. The compiler must insert a type 
  2446. check, or if type checks are disabled, the program might give wrong results. 
  2447. Since one of the fundamental properties of map is that it transforms lists, we 
  2448. should make the relationship between the input pairs and the result pairs more 
  2449. apparent in the code: 
  2450.  
  2451. (define (map f lst)
  2452.   (cond ((pair? lst)
  2453.          (cons (f (car lst)) (map f (cdr lst))))
  2454.         ((null? lst)
  2455.          '())
  2456.         (else
  2457.          ...) ; You decide - '() or an error?
  2458.  
  2459. Note also that the pair? case comes first because we expect that map will be 
  2460. called on lists which have, on average, length greater that one. 
  2461.  
  2462.  
  2463. ΓòÉΓòÉΓòÉ 7.3.1.2. Internal procedures ΓòÉΓòÉΓòÉ
  2464.  
  2465. Calls to internal procedures are faster than calls to global procedures. There 
  2466. are two things that make internal procedures faster: First, the procedure call 
  2467. is compiled to a direct jump to a known location, which is more efficient that 
  2468. jumping `via' a global binding. Second, there is a knock-on effect: since the 
  2469. compiler can see the internal procedure, the compiler can analyze it and 
  2470. possibly produce better code for other expressions in the body of the loop too: 
  2471.  
  2472. (define (map f original-lst)
  2473.   (let walk ((lst original-lst))
  2474.     (cond ((pair? lst)
  2475.            (cons (f (car lst)) (walk (cdr lst))))
  2476.           ((null? lst)
  2477.            '())
  2478.           (else
  2479.            (error "Not a proper list:"  original-lst)))))
  2480.  
  2481.  
  2482. ΓòÉΓòÉΓòÉ 7.3.1.3. Internal defines ΓòÉΓòÉΓòÉ
  2483.  
  2484. Internal definitions are a useful tool for structuring larger procedures. 
  2485. However, certain internal definitions can thwart compiler optimizations. 
  2486. Consider the following two procedures, where compute-100 is some unknown 
  2487. procedure that we just know returns `100'. 
  2488.  
  2489. (define (f1)
  2490.   (define v 100)
  2491.   (lambda () v))
  2492.  
  2493. (define (f2)
  2494.   (define v (compute-100))
  2495.   (lambda () v))
  2496.  
  2497. The procedure returned by f1 will always give the same result and the compiler 
  2498. can prove this.  The procedure returned by f2 may return different results, 
  2499. even if f2 is only called once. Because of this, the compiler has to allocate a 
  2500. memory cell to v. How can the procedure return different results? 
  2501.  
  2502. The fundamental reason is that the continuation may escape during the 
  2503. evaluation of (compute-100), allowing the rest of the body of f2 to be executed 
  2504. again: 
  2505.  
  2506. (define keep)
  2507.  
  2508. (define (compute-100)
  2509.   (call-with-current-continuation
  2510.    (lambda (k)
  2511.      (set! keep k)
  2512.      100)))
  2513.  
  2514. (define p (f2))
  2515.  
  2516. (p)                => 100
  2517. (keep -999)        => p     re-define v and p
  2518. (p)                => -999
  2519.  
  2520. To avoid the inefficiency introduced to handle the general case, the compiler 
  2521. must prove that the continuation cannot possibly escape.  The compiler knows 
  2522. that lambda expressions and constants do not let their continuations escape, so 
  2523. order the internal definitions so that definitions of the following forms come 
  2524. first: 
  2525.  
  2526. (define x 'something)
  2527. (define x (lambda (...) ...))
  2528. (define (f u v) ...)
  2529.  
  2530.  
  2531. ΓòÉΓòÉΓòÉ 7.3.2. Global variables ΓòÉΓòÉΓòÉ
  2532.  
  2533. Compiled code usually accesses variables in top-level first-class environments 
  2534. via variable caches.  Each compiled procedure has a set of variable caches for 
  2535. the global variables that it uses.  There are three kinds of variable cache - 
  2536. read caches for getting the value of a variable (referencing the variable), 
  2537. write caches for changing the value, and execute caches for calling the 
  2538. procedure assigned to that variable. 
  2539.  
  2540. Sometimes the variable caches contain special objects, called reference traps, 
  2541. that indicate that the operation cannot proceed normally and must either be 
  2542. completed by the system (in order to keep the caches coherent) or must signal 
  2543. an error.  For example, the assignment 
  2544.  
  2545. (set! newline my-better-newline)
  2546.  
  2547. will cause the system to go to each compiled procedure that calls newline and 
  2548. update its execute cache to call the new procedure. Obviously you want to avoid 
  2549. updating hundreds of of execute caches in a critical loop.  Using fluid-let to 
  2550. temporarily redefine a procedure has the same inefficiency (but twice!). 
  2551.  
  2552. To behave correctly in all situations, each variable reference or assignment 
  2553. must check for the reference traps. 
  2554.  
  2555. Sometimes you can prove that the variable (a) will always be bound, (b) will 
  2556. always be assigned and (c) there will never be any compiled calls to that 
  2557. variable.  The compiler can't prove this because it assumes that other, 
  2558. independently compiled, files might be loaded that invalidate these 
  2559. assumptions. If you know that these conditions hold, the following declarations 
  2560. can speed up and reduce the size of a program that uses global variables. 
  2561.  
  2562. -- declaration+: ignore-reference-traps variables 
  2563. This declaration tells the compiler that it need not check for reference-trap 
  2564. objects when referring to the given variables. If any of the variables is 
  2565. unbound or unassigned then a variable reference will yield a reference-trap 
  2566. object rather than signaling an error.  This declaration is relatively safe: 
  2567. the worst that can happen is that a reference-trap object finds its way into a 
  2568. data structure (e.g. a list) or into interpreted code, in which case it will 
  2569. probably cause some `unrelated' variable to mysteriously become unbound or 
  2570. unassigned. 
  2571.  
  2572. -- declaration+: ignore-assignment-traps variables 
  2573. This declaration tells the compiler that it need not check for reference-trap 
  2574. objects when assigning to the given variables.  An assignment to a variable 
  2575. that ignores assignment traps can cause a great deal of trouble.  If there is a 
  2576. compiled procedure call anywhere in the system to this variable, the execute 
  2577. caches will not be updated, causing an inconsistency between the value used for 
  2578. the procedure call and the value seen by reading the variable.  This mischief 
  2579. is compounded by the fact that the assignment can cause other assignments that 
  2580. were compiled with checks to behave this way too. 
  2581.  
  2582. The variables are specified with expressions from the following set language: 
  2583.  
  2584. -- variable-specification: set name ... 
  2585. All of the explicitly listed names. 
  2586.  
  2587. -- variable-specification: all 
  2588. -- variable-specification: none 
  2589. -- variable-specification: free 
  2590. -- variable-specification: bound 
  2591. -- variable-specification: assigned 
  2592. These expressions name sets of variables. all is the set of all variables, none 
  2593. is the empty set, free is all of the variables bound outside the current block, 
  2594. bound is all of the variables bound in the current block and assigned is all of 
  2595. the variables for which there exists an assignment (i.e.@ set!). 
  2596.  
  2597. -- variable-specification: union set1 set2 
  2598. -- variable-specification: intersection set1 set2 
  2599. -- variable-specification: difference set1 set2 
  2600.  
  2601. For example, to ignore reference traps on all the variables except x, y and any 
  2602. variable that is assigned to 
  2603.  
  2604. (declare (ignore-reference-traps
  2605.           (difference all (union assigned (set x y)))))
  2606.  
  2607.  
  2608. ΓòÉΓòÉΓòÉ 7.3.3. Fixnum arithmetic ΓòÉΓòÉΓòÉ
  2609.  
  2610. The usual arithmetic operations like + and < are called generic arithmetic 
  2611. operations because they work for all (appropriate) kinds of number. 
  2612.  
  2613. A fixnum is an exact integer that is small enough to fit in a machine word.  In 
  2614. MIT Scheme, fixnums are typically 24 or 26 bits, depending on the machine; it 
  2615. is reasonable to assume that fixnums are at least 24 bits.  Fixnums are signed; 
  2616. they are encoded using 2's complement. 
  2617.  
  2618. All exact integers that are small enough to be encoded as fixnums are always 
  2619. encoded as fixnums --- in other words, any exact integer that is not a fixnum 
  2620. is too big to be encoded as such.  For this reason, small constants such as 0 
  2621. or 1 are guaranteed to be fixnums.  In addition, the lengths of and valid 
  2622. indexes into strings and vectors are also always fixnums. 
  2623.  
  2624. If you know that a value is always a small fixnum, you can substitute the 
  2625. equivalent fixnum operation for the generic operation.  However, care should be 
  2626. exercised: if used improperly, these operations can return incorrect answers, 
  2627. or even malformed objects that confuse the garbage collector.  The Scheme 
  2628. Reference Manual lists all the fixnum operations. 
  2629.  
  2630. A fruitful area for inserting fixnum operations is in the index operations in 
  2631. tight loops. 
  2632.  
  2633.  
  2634. ΓòÉΓòÉΓòÉ 7.3.4. Flonum arithmetic ΓòÉΓòÉΓòÉ
  2635.  
  2636. Getting efficient flonum arithmetic is much more complicated and harder than 
  2637. getting efficient fixnum arithmetic. 
  2638.  
  2639.  
  2640. ΓòÉΓòÉΓòÉ 7.3.4.1. Flonum consing ΓòÉΓòÉΓòÉ
  2641.  
  2642. One of the main disadvantages of generic arithmetic is that not all kinds of 
  2643. number fit in a machine register. Flonums have to be boxed because a 64-bit 
  2644. ieee floating-point number (the representation that MIT Scheme uses) does not 
  2645. fit in a regular machine word. This is true even on 64-bit architectures 
  2646. because some extra bits are needed to distinguish floating-point numbers from 
  2647. other objects like pairs and strings. Values are boxed by storing them in a 
  2648. small record in the heap. Every floating-point value that you see at the repl 
  2649. is boxed. Floating-point values are unboxed only for short periods of time when 
  2650. they are in the machine's floating-point unit and actual floating-point 
  2651. operations are being performed. 
  2652.  
  2653. Numerical calculations that happen to be using floating-point numbers cause 
  2654. many temporary floating-point numbers to be allocated.  It is not uncommon for 
  2655. numerical programs to spend over half of their time creating and garbage 
  2656. collecting the boxed flonums. 
  2657.  
  2658. Consider the following procedure for computing the distance of a point (x,y) 
  2659. from the origin. 
  2660.  
  2661. (define (distance x y)
  2662.   (sqrt (+ (* x x) (* y y))))
  2663.  
  2664. The call (distance 0.3 0.4) returns a new, boxed flonum, 0.5. The calculation 
  2665. also generates three intermediate boxed flonums.  This next version works only 
  2666. for flonum inputs, generates only one boxed flonum (the result) and runs eight 
  2667. times faster: 
  2668.  
  2669. (define (flo:distance x y)
  2670.   (flo:sqrt (flo:+ (flo:* x x) (flo:* y y))))
  2671.  
  2672. Note that flo: operations are usually effective only within a single arithmetic 
  2673. expression.  If the expression contains conditionals or calls to procedures 
  2674. then the values tend to get boxed anyway. 
  2675.  
  2676.  
  2677. ΓòÉΓòÉΓòÉ 7.3.4.2. Flonum vectors ΓòÉΓòÉΓòÉ
  2678.  
  2679. Flonum vectors are vectors that contain only floating-point values, in much the 
  2680. same way as a string is a `vector' containing only character values. 
  2681.  
  2682. Flonum vectors have the advantages of compact storage (about half that of a 
  2683. conventional vector of flonums) and judicious use of flonum vectors can 
  2684. decrease flonum consing. 
  2685.  
  2686. The disadvantages are that flonum vectors are incompatible with ordinary 
  2687. vectors, and if not used carefully, can increase flonum consing.  Flonum 
  2688. vectors are a pain to use because they require you to make a decision about the 
  2689. representation and stick with it, and it might not be easy to ascertain whether 
  2690. the advantages in one part of the program outweigh the disadvantages in 
  2691. another. 
  2692.  
  2693. The flonum vector operations are: 
  2694.  
  2695. -- procedure+: flo:vector-cons n 
  2696. Create a flonum vector of length N. The contents of the vector are arbitrary 
  2697. and might not be valid floating-point numbers. The contents should not be used 
  2698. until initialized. 
  2699.  
  2700. -- procedure+: flo:vector-ref flonum-vector index 
  2701. -- procedure+: flo:vector-set! flonum-vector index value 
  2702. -- procedure+: flo:vector-length flonum-vector 
  2703. These operations are analogous to the ordinary vector operations. 
  2704.  
  2705.  
  2706. ΓòÉΓòÉΓòÉ 7.3.4.3. Examples ΓòÉΓòÉΓòÉ
  2707.  
  2708. The following operation causes no flonum consing because the flonum is loaded 
  2709. directly from the flonum vector into a floating-point machine register, added, 
  2710. and stored again.  There is no need for a temporary boxed flonum. 
  2711.  
  2712. (flo:vector-set v 0 (flo:+ (flo:vector-ref v 0) 1.2))
  2713.  
  2714. In this next example, every time g is called, a new boxed flonum has to be 
  2715. created so that a valid Scheme object can be returned.  If g is called more 
  2716. often than the elements of v are changed then an ordinary vector might be more 
  2717. efficient. 
  2718.  
  2719. (define (g i)
  2720.   (flo:vector-ref v i))
  2721.  
  2722.  
  2723. ΓòÉΓòÉΓòÉ 7.3.4.4. Common pitfalls ΓòÉΓòÉΓòÉ
  2724.  
  2725. Pitfall 1: Make sure that your literals are floating-point constants: 
  2726.  
  2727. (define (f1 a) (flo:+ a 1))
  2728. (define (f2 a) (flo:+ a 1.))
  2729.  
  2730. f1 will most likely cause a hardware error, and certainly give the wrong 
  2731. answer.  f2 is correct. 
  2732.  
  2733. Pitfall 2: It is tempting to insert calls to exact->inexact to coerce values 
  2734. into flonums.  This does not always work because complex numbers may be exact 
  2735. or inexact too.  Also, the current implementation of exact->inexact is slow. 
  2736.  
  2737. Pitfall 3: A great deal of care has to be taken with the standard math 
  2738. procedures. For example, when called with a flonum, both sqrt and asin can 
  2739. return a complex number (e.g -1.5). 
  2740.  
  2741.  
  2742. ΓòÉΓòÉΓòÉ 8. Debugging ΓòÉΓòÉΓòÉ
  2743.  
  2744. *This chapter is out of date and will be revised*. 
  2745.  
  2746. This chapter is adapted from Don't Panic: A 6.001 User's Guide to the Chipmunk 
  2747. System, by Arthur A. Gleckler. 
  2748.  
  2749. Even computer software that has been planned carefully and written well may not 
  2750. always work correctly.  Mysterious creatures called bugs may creep in and wreak 
  2751. havoc, leaving the programmer to clean up the mess.  Some have theorized that a 
  2752. program fails only because its author made a mistake, but experienced computer 
  2753. programmers know that bugs are always to blame.  This is why the task of fixing 
  2754. broken computer software is called debugging. 
  2755.  
  2756. It is impossible to prove the correctness of any non-trivial program; hence the 
  2757. Cynic's First Law of Debugging: 
  2758.  
  2759. Programs don't become more reliable as they are debugged; the bugs just get 
  2760. harder to find. 
  2761.  
  2762. Scheme is equipped with a variety of special software for finding and removing 
  2763. bugs.  The debugging tools include facilities for tracing a program's use of 
  2764. specified procedures, for examining Scheme environments, and for setting 
  2765. breakpoints, places where the program will pause for inspection. 
  2766.  
  2767. Many bugs are detected when programs try to do something that is impossible, 
  2768. like adding a number to a symbol, or using a variable that does not exist; this 
  2769. type of mistake is called an error. Whenever an error occurs, Scheme prints an 
  2770. error message and starts a new repl.  For example, using a nonexistent variable 
  2771. foo will cause Scheme to respond 
  2772.  
  2773. 1 ]=> foo
  2774.  
  2775. ;Unbound variable: foo
  2776. ;To continue, call RESTART with an option number:
  2777. ; (RESTART 3) => Specify a value to use instead of foo.
  2778. ; (RESTART 2) => Define foo to a given value.
  2779. ; (RESTART 1) => Return to read-eval-print level 1.
  2780.  
  2781. 2 error>
  2782.  
  2783. Sometimes, a bug will never cause an error, but will still cause the program to 
  2784. operate incorrectly.  For instance, 
  2785.  
  2786. (prime? 7)   =>   #f
  2787.  
  2788. In this situation, Scheme does not know that the program is misbehaving. The 
  2789. programmer must notice the problem and, if necessary, start the debugging tools 
  2790. manually. 
  2791.  
  2792. There are several approaches to finding bugs in a Scheme program: 
  2793.  
  2794.      Inspect the original Scheme program. 
  2795.  
  2796.      Use the debugging tools to follow your program's progress. 
  2797.  
  2798.      Edit the program to insert checks and breakpoints. 
  2799.  
  2800.  Only experience can teach how to debug programs, so be sure to experiment with 
  2801.  all these approaches while doing your own debugging. Planning ahead is the 
  2802.  best way to ward off bugs, but when bugs do appear, be prepared to attack them 
  2803.  with all the tools available. 
  2804.  
  2805.  
  2806. ΓòÉΓòÉΓòÉ 8.1. Subproblems and Reductions ΓòÉΓòÉΓòÉ
  2807.  
  2808. Understanding the concepts of reduction and subproblem is essential to good use 
  2809. of the debugging tools.  The Scheme interpreter evaluates an expression by 
  2810. reducing it to a simpler expression. In general, Scheme's evaluation rules 
  2811. designate that evaluation proceeds from one expression to the next by either 
  2812. starting to work on a subexpression of the given expression, or by reducing the 
  2813. entire expression to a new (simpler, or reduced) form.  Thus, a history of the 
  2814. successive forms processed during the evaluation of an expression will show a 
  2815. sequence of subproblems, where each subproblem may consist of a sequence of 
  2816. reductions. 
  2817.  
  2818. For example, both (+ 5 6) and (+ 7 9) are subproblems of the following 
  2819. combination: 
  2820.  
  2821. (* (+ 5 6) (+ 7 9))
  2822.  
  2823. If (prime? n) is true, then (cons 'prime n) is a reduction for the following 
  2824. expression: 
  2825.  
  2826. (if (prime? n)
  2827.     (cons 'prime n)
  2828.     (cons 'not-prime n))
  2829.  
  2830. This is because the entire subproblem of the if expression can be reduced to 
  2831. the problem (cons 'prime n), once we know that (prime?  n) is true; the (cons 
  2832. 'not-prime n) can be ignored, because it will never be needed.  On the other 
  2833. hand, if (prime? n) were false, then (cons 'not-prime n) would be the reduction 
  2834. for the if expression. 
  2835.  
  2836. The subproblem level is a number representing how far back in the history of 
  2837. the current computation a particular evaluation is.  Consider factorial: 
  2838.  
  2839. (define (factorial n)
  2840.   (if (< n 2)
  2841.       1
  2842.       (* n (factorial (- n 1)))))
  2843.  
  2844. If we stop factorial in the middle of evaluating (- n 1), the (- n 1) is at 
  2845. subproblem level 0.  Following the history of the computation "upwards," 
  2846. (factorial (- n 1)) is at subproblem level 1, and (* n (factorial (- n 1))) is 
  2847. at subproblem level 2. These expressions all have reduction number 0. 
  2848. Continuing upwards, the if expression has reduction number 1. 
  2849.  
  2850. Moving backwards in the history of a computation, subproblem levels and 
  2851. reduction numbers increase, starting from zero at the expression currently 
  2852. being evaluated.  Reduction numbers increase until the next subproblem, where 
  2853. they start over at zero.  The best way to get a feel for subproblem levels and 
  2854. reduction numbers is to experiment with the debugging tools, especially debug. 
  2855.  
  2856.  
  2857. ΓòÉΓòÉΓòÉ 8.2. The Debugger ΓòÉΓòÉΓòÉ
  2858.  
  2859. There are three debuggers available with MIT Scheme.  Two of them require and 
  2860. run under Edwin, and are described in that section of this document (see 
  2861. Edwin).  The third is command oriented, does not require Edwin, and is 
  2862. described here. 
  2863.  
  2864. The debugger, called debug, is the tool you should use when Scheme signals an 
  2865. error and you want to find out what caused the error. When Scheme signals an 
  2866. error, it records all the information necessary to continue running the Scheme 
  2867. program that caused the error; the debugger provides you with the means to 
  2868. inspect this information.  For this reason, the debugger is sometimes called a 
  2869. continuation browser. 
  2870.  
  2871. Here is the transcript of a typical Scheme session, showing a user evaluating 
  2872. the expression (fib 10), Scheme responding with an unbound variable error for 
  2873. the variable fob, and the user starting the debugger: 
  2874.  
  2875. 1 ]=> (fib 10)
  2876.  
  2877. ;Unbound variable: fob
  2878. ;To continue, call RESTART with an option number:
  2879. ; (RESTART 3) => Specify a value to use instead of fob.
  2880. ; (RESTART 2) => Define fob to a given value.
  2881. ; (RESTART 1) => Return to read-eval-print level 1.
  2882.  
  2883. 2 error> (debug)
  2884.  
  2885. There are 6 subproblems on the stack.
  2886.  
  2887. Subproblem level: 0 (this is the lowest subproblem level)
  2888. Expression (from stack):
  2889.     fob
  2890. Environment created by the procedure: FIB
  2891.  applied to: (10)
  2892. The execution history for this subproblem contains 1 reduction.
  2893. You are now in the debugger.  Type q to quit, ? for commands.
  2894.  
  2895. 3 debug>
  2896.  
  2897. This tells us that the error occurred while trying to evaluate the expression 
  2898. fob while running (fib 10).  It also tells us this is subproblem level 0, the 
  2899. first of 8 subproblems that are available for us to examine.  The expression 
  2900. shown is marked "(from stack)", which tells us that this expression was 
  2901. reconstructed from the interpreter's internal data structures.  Another source 
  2902. of information is the execution history, which keeps a record of expressions 
  2903. evaluated by the interpreter.  The debugger informs us that the execution 
  2904. history has recorded some information for this subproblem, specifically a 
  2905. description of one reduction. 
  2906.  
  2907.  
  2908. ΓòÉΓòÉΓòÉ 8.3. Debugging Aids ΓòÉΓòÉΓòÉ
  2909.  
  2910. An important step in debugging is to locate the piece of code from which the 
  2911. error is signalled.  The Scheme debugger contains a history examiner and an 
  2912. environment examiner to aid the user in locating a bug. 
  2913.  
  2914. -- special form+: bkpt message irritant 
  2915. Sets a breakpoint.  When the breakpoint is encountered, message and irritant 
  2916. are typed and a read-eval-print loop is entered in the current environment.  To 
  2917. exit from the breakpoint and proceed with the interrupted process, call the 
  2918. procedure continue.  Sample usage: 
  2919.  
  2920. 1 ]=> (begin (write-line 'foo)
  2921.              (bkpt 'test-2 'test-3)
  2922.              (write-line 'bar)
  2923.              'done)
  2924.  
  2925. foo
  2926.  test-2 test-3
  2927. ;To continue, call RESTART with an option number:
  2928. ; (RESTART 2) => Return from BKPT.
  2929. ; (RESTART 1) => Return to read-eval-print level 1.
  2930.  
  2931. 2 bkpt> (+ 3 3)
  2932.  
  2933. ;Value: 6
  2934.  
  2935. 2 bkpt> (proceed)
  2936.  
  2937. bar
  2938. ;Value: done
  2939.  
  2940. -- procedure+: pp object [output-port [as-code?]] 
  2941. -- procedure+: pa procedure 
  2942. The pp procedure is described in the MIT Scheme Reference Manual. We just note 
  2943. here that, by default, MIT Scheme keeps debugging information, so pp is useful 
  2944. for looking at the source code of a procedure (compiled or interpreted). 
  2945.  
  2946. pa prints the arguments of procedure.  This can be used to remind yourself, for 
  2947. example, of the correct order of the arguments to a procedure. 
  2948.  
  2949. 1 ]=> for-all?
  2950. ;Value 40: #[compiled-procedure 40 ("boole" #x6) #xC #x20ECB0]
  2951.  
  2952. 1 ]=> (pa for-all?)
  2953. (items predicate)
  2954. ;No value
  2955.  
  2956. 1 ]=> (pp for-all?)
  2957. (named-lambda (for-all? items predicate)
  2958.   (let loop ((items items))
  2959.     (or (null? items)
  2960.         (and (predicate (car items))
  2961.              (loop (cdr items))))))
  2962.  
  2963. -- procedure+: where [obj] 
  2964. The procedure where enters the environment examination system. This allows 
  2965. environments and variable bindings to be examined and modified.  where accepts 
  2966. one-letter commands.  The commands can be found by typing ? to the `where>' 
  2967. prompt.  The optional argument, obj, is an object with an associated 
  2968. environment: an environment, a procedure, or a promise.  If obj is omitted, the 
  2969. environment examined is the read-eval-print environment from which where was 
  2970. called (or an error or breakpoint environment if called from the debugger).  If 
  2971. a procedure is supplied, where lets the user examine the closing environment of 
  2972. the procedure.  This is useful for debugging procedure arguments and values. 
  2973.  
  2974. -- procedure+: apropos string [package/env [search-parents?]] 
  2975. Search an environment for bound names containing string and print out the 
  2976. matching bound names.  If package/env is specified, it must be an environment 
  2977. or package name, and it defaults to the current repl environment.  The flag 
  2978. search-parents? specifies whether the environment's parents should be included 
  2979. in the search.  The default is #f if package/env is specified, and #t if 
  2980. package/env is not specified. 
  2981.  
  2982. 1 ]=> (apropos "search")
  2983. #[package 41 (user)]
  2984. #[package 33 ()]
  2985. list-search-negative
  2986. list-search-positive
  2987. search-ordered-subvector
  2988. search-ordered-vector
  2989. vector-binary-search
  2990. ;No value
  2991.  
  2992.  
  2993. ΓòÉΓòÉΓòÉ 8.4. Advising Procedures ΓòÉΓòÉΓòÉ
  2994.  
  2995. Giving advice to procedures is a powerful debugging technique. trace and break 
  2996. are useful examples of advice-giving procedures. Note that the advice system 
  2997. only works for interpreted procedures. 
  2998.  
  2999. -- procedure+: trace-entry procedure 
  3000. Causes an informative message to be printed whenever procedure is entered.  The 
  3001. message is of the form 
  3002.  
  3003. [Entering #[compound-procedure 1 foo]
  3004.     Args: val1
  3005.           val2
  3006.           ...]
  3007.  
  3008. where val1, val2 etc. are the evaluated arguments supplied to the procedure. 
  3009.  
  3010. -- procedure+: trace-exit procedure 
  3011. Causes an informative message to be printed when procedure terminates.  The 
  3012. message contains the procedure, its argument values, and the value returned by 
  3013. the procedure. 
  3014.  
  3015. -- procedure+: trace-both procedure 
  3016. -- procedure+: trace procedure 
  3017. Equivalent to calling both trace-entry and trace-exit on procedure.  trace is 
  3018. the same as trace-both. 
  3019.  
  3020. -- procedure+: untrace-entry [procedure] 
  3021. Stops tracing the entry of procedure.  If procedure is not given, the default 
  3022. is to stop tracing the entry of all entry-traced procedures. 
  3023.  
  3024. -- procedure+: untrace-exit [procedure] 
  3025. Stops tracing the exit of procedure.  If procedure is not given, the default is 
  3026. all exit-traced procedures. 
  3027.  
  3028. -- procedure+: untrace [procedure] 
  3029. Stops tracing both the entry to and the exit from procedure.  If procedure is 
  3030. not given, the default is all traced procedures. 
  3031.  
  3032. -- procedure+: break-entry procedure 
  3033. Like trace-entry with the additional effect that a breakpoint is entered when 
  3034. procedure is invoked.  Both procedure and its arguments can be accessed by 
  3035. calling the procedures *proc* and *args*, respectively.  Use restart or 
  3036. continue to continue from a breakpoint. 
  3037.  
  3038. -- procedure+: break-exit procedure 
  3039. Like trace-exit, except that a breakpoint is entered just prior to leaving 
  3040. procedure.  Procedure, its arguments, and the result can be accessed by calling 
  3041. the procedures *proc*, *args*, and *result*, respectively.  Use restart or 
  3042. continue to continue from a breakpoint. 
  3043.  
  3044. -- procedure+: break-both procedure 
  3045. -- procedure+: break procedure 
  3046. Sets a breakpoint at the beginning and end of procedure.  This is break-entry 
  3047. and break-exit combined. 
  3048.  
  3049. -- procedure+: unbreak [procedure] 
  3050. Discontinues the entering of a breakpoint on the entry to and exit from 
  3051. procedure.  If procedure is not given, the default is all breakpointed 
  3052. procedures. 
  3053.  
  3054. -- procedure+: unbreak-entry [procedure] 
  3055. Discontinues the entering of a breakpoint on the entry to procedure.  If 
  3056. procedure is not given, the default is all entry-breakpointed procedures. 
  3057.  
  3058. -- procedure+: unbreak-exit [procedure] 
  3059. Discontinues the entering of a breakpoint on the exit from procedure.  If 
  3060. procedure is not given, the default is all exit-breakpointed procedures. 
  3061.  
  3062. The following three procedures are valid only within the dynamic extent of a 
  3063. breakpoint.  In other words, don't call them unless you are stopped inside a 
  3064. breakpoint. 
  3065.  
  3066. -- procedure+: *proc* 
  3067. Returns the procedure in which the breakpoint has stopped. 
  3068.  
  3069. -- procedure+: *args* 
  3070. Returns the arguments to the procedure in which the breakpoint has stopped. 
  3071. The arguments are returned as a list. 
  3072.  
  3073. -- procedure+: *result* 
  3074. Returns the result yielded by the procedure in which the breakpoint has 
  3075. stopped.  This is valid only when in an exit breakpoint. 
  3076.  
  3077. The following procedures install advice procedures that are called when the 
  3078. advised procedure is entered or exited.  An entry-advice procedure must accept 
  3079. three arguments: the advised procedure, a list of the advised procedure's 
  3080. arguments, and the advised procedure's application environment (that is, the 
  3081. environment in which the procedure's formal parameters are bound).  An 
  3082. exit-advice procedure must accept four arguments: the advised procedure, a list 
  3083. of the advised procedure's arguments, the result yielded by the advised 
  3084. procedure, and the advised procedure's application environment. 
  3085.  
  3086. Note that the trace and breakpoint procedures described above are all 
  3087. implemented by means of the more general advice procedures, so removing advice 
  3088. from an advised procedure will also remove traces and breakpoints. 
  3089.  
  3090. -- procedure+: advise-entry procedure advice 
  3091. Advice must be an entry-advice procedure.  Advice is attached to procedure, so 
  3092. that whenever procedure is entered, advice is called. 
  3093.  
  3094. -- procedure+: advise-exit procedure advice 
  3095. Advice must be an exit-advice procedure.  Advice is attached to procedure, so 
  3096. that whenever procedure returns, advice is called. 
  3097.  
  3098. -- procedure+: advice procedure 
  3099. Returns the advice procedures, if any, that are attached to procedure.  This is 
  3100. returned as a list of two lists: the first list is all of the entry-advice 
  3101. procedures attached to procedure, and the second is all of the exit-advice 
  3102. procedures. 
  3103.  
  3104. -- procedure+: unadvise-entry [procedure] 
  3105. Removes all entry-advice procedures from procedure.  If procedure is not given, 
  3106. the default is all entry-advised procedures. 
  3107.  
  3108. -- procedure+: unadvise-exit [procedure] 
  3109. Removes exit-advice procedures from procedure.  If procedure is not given, the 
  3110. default is all exit-advised procedures. 
  3111.  
  3112. -- procedure+: unadvise [procedure] 
  3113. Removes all advice procedures from procedure. This is a combination of 
  3114. unadvise-entry and unadvise-exit.  If procedure is not given, the default is 
  3115. all advised procedures. 
  3116.  
  3117.  
  3118. ΓòÉΓòÉΓòÉ 9. GNU Emacs Interface ΓòÉΓòÉΓòÉ
  3119.  
  3120. There is an interface library, called `xscheme', distributed with MIT Scheme 
  3121. and GNU Emacs, which facilitates running Scheme as a subprocess of Emacs.  If 
  3122. you wish to use this interface, please install the version of `xscheme.el' that 
  3123. comes with MIT Scheme, as it is guaranteed to be correct for your version of 
  3124. Scheme. 
  3125.  
  3126. Note that this interface is supported under Unix only.  We have explored the 
  3127. possibility of making it work under OS/2 and concluded that it is impossible. 
  3128.  
  3129. To invoke Scheme from Emacs, use M-x run-scheme, which is defined when either 
  3130. of the libraries `scheme' or `xscheme' is loaded. You may give run-scheme a 
  3131. prefix argument, in which case it will allow you to edit the command line that 
  3132. is used to invoke Scheme. Do not remove the `-emacs' option! 
  3133.  
  3134. Note carefully: In Emacs 19, the run-scheme command exists, but is different 
  3135. from the one described here!  In order to get this interface, you must load the 
  3136. `xscheme' library before executing run-scheme. 
  3137.  
  3138. Scheme will be started up as a subprocess in a buffer called `*scheme*'.  This 
  3139. buffer will be in scheme-interaction-mode and all output from the Scheme 
  3140. process will go there.  The mode line for the `*scheme*' buffer will have this 
  3141. form: 
  3142.  
  3143. --**-*scheme*: 1 [Evaluator]           (Scheme Interaction: input)------
  3144.  
  3145. The first field, showing `1' in this example, is the level number. 
  3146.  
  3147. The second field, showing `[Evaluator]' in this example, describes the type of 
  3148. repl that is running.  Other values include: 
  3149.  
  3150. [Debugger]
  3151. [Where]
  3152.  
  3153. The mode after `Scheme Interaction' is one of: 
  3154.  
  3155.  `input' 
  3156.            Scheme is waiting for input. 
  3157.  
  3158.  `run' 
  3159.            Scheme is running an evaluation. 
  3160.  
  3161.  `gc' 
  3162.            Scheme is garbage collecting. 
  3163.  
  3164.  When `xscheme' is loaded, scheme-mode is extended to include commands for 
  3165.  evaluating expressions (do C-h m in any scheme-mode buffer for the most 
  3166.  up-to-date information): 
  3167.  
  3168.  ESC o 
  3169.            Evaluates the current buffer (xscheme-send-buffer). 
  3170.  
  3171.  ESC z 
  3172.            Evaluates the current definition (xscheme-send-definition).  This is 
  3173.            also bound to ESC C-x. 
  3174.  
  3175.  ESC C-z 
  3176.            Evaluates the current region (xscheme-send-region). 
  3177.  
  3178.  C-x C-e 
  3179.            Evaluates the expression to the left of point 
  3180.            (xscheme-send-previous-expression).  This is also bound to ESC RET. 
  3181.  
  3182.  C-c C-s 
  3183.            Selects the `*scheme*' buffer and places you at its end 
  3184.            (xscheme-select-process-buffer). 
  3185.  
  3186.  C-c C-y 
  3187.            Yanks the most recently evaluated expression, placing it at point 
  3188.            (xscheme-yank-previous-send).  This works only in the `*scheme*' 
  3189.            buffer. 
  3190.  
  3191.  The following commands provide interrupt capability: 
  3192.  
  3193.  C-c C-c 
  3194.            Like typing C-g when running Scheme without Emacs. 
  3195.            (xscheme-send-control-g-interrupt) 
  3196.  
  3197.  C-c C-x 
  3198.            Like typing C-c C-x when running Scheme without Emacs. 
  3199.            (xscheme-send-control-x-interrupt) 
  3200.  
  3201.  C-c C-u 
  3202.            Like typing C-c C-u when running Scheme without Emacs. 
  3203.            (xscheme-send-control-u-interrupt) 
  3204.  
  3205.  C-c C-b 
  3206.            Like typing C-c C-b when running Scheme without Emacs. 
  3207.            (xscheme-send-breakpoint-interrupt) 
  3208.  
  3209.  C-c C-p 
  3210.            Like evaluating (proceed) or (continue). 
  3211.            (xscheme-send-proceed) 
  3212.  
  3213.  
  3214. ΓòÉΓòÉΓòÉ 10. Edwin ΓòÉΓòÉΓòÉ
  3215.  
  3216. This chapter describes how to start Edwin, the MIT Scheme text editor. Edwin is 
  3217. very similar to GNU Emacs --- you should refer to the GNU Emacs manual for 
  3218. information about Edwin's commands and key bindings --- except that Edwin's 
  3219. extension language is MIT Scheme, while GNU Emacs extensions are written in 
  3220. Emacs Lisp.  This manual does not discuss customization of Edwin. 
  3221.  
  3222.  
  3223. ΓòÉΓòÉΓòÉ 10.1. Starting Edwin ΓòÉΓòÉΓòÉ
  3224.  
  3225. To use Edwin, start Scheme with a world image containing Edwin (for example by 
  3226. giving the `-edwin' command-line option), then call the procedure edit: 
  3227.  
  3228. -- procedure+: edit 
  3229. -- procedure+: edwin 
  3230. Enter the Edwin text editor.  If entering for the first time, the editor is 
  3231. initialized (by calling create-editor with no arguments). Otherwise, the 
  3232. previously-initialized editor is reentered. 
  3233.  
  3234. This procedure is sometimes evaluated from the command line to start Scheme 
  3235. with Edwin running: 
  3236.  
  3237. scheme -edwin -eval (edit)
  3238.  
  3239. The procedure edwin is an alias for edit. 
  3240.  
  3241. -- variable+: inhibit-editor-init-file? 
  3242. When Edwin is first initialized, it loads your init file (called `~/.edwin' 
  3243. under Unix, `edwin.ini' on PCs) if you have one.  If the Scheme variable 
  3244. inhibit-editor-init-file? is true, however, your init file will not be loaded 
  3245. even if it exists.  By default, this variable is false. 
  3246.  
  3247. -- procedure+: create-editor arg ... 
  3248. Initializes Edwin, or reinitializes it if already initialized. create-editor is 
  3249. normally invoked automatically by edit. 
  3250.  
  3251. If no args are given, the value of create-editor-args is used instead.  In 
  3252. other words, the following are equivalent: 
  3253.  
  3254. (create-editor)
  3255. (apply create-editor create-editor-args)
  3256.  
  3257. On the other hand, if args are given, they are used to update 
  3258. codecreate-editor-args, making the following equivalent: 
  3259.  
  3260. (apply create-editor args)
  3261. (begin (set! create-editor-args args) (create-editor))
  3262.  
  3263. -- variable+: create-editor-args 
  3264. This variable controls the initialization of Edwin.  The following values are 
  3265. defined: 
  3266.  
  3267.  (#f) 
  3268.            This is the default.  Creates a window of some default size, and 
  3269.            uses that window as Edwin's main window.  Under Unix, if X11 is not 
  3270.            available or if the `DISPLAY' environment variable is undefined, 
  3271.            Edwin will run on Scheme's console. 
  3272.  
  3273.  (x) 
  3274.            Unix only.  Creates an X window and uses it as Edwin's main window. 
  3275.            This requires the `DISPLAY' environment variable to have been set to 
  3276.            the appropriate value before Scheme was started. 
  3277.  
  3278.  (x geometry) 
  3279.            Unix only.  Like (x) except that geometry specifies the window's 
  3280.            geometry in the usual way.  Geometry must be a character string 
  3281.            whose contents is an X geometry specification. 
  3282.  
  3283.  (console) 
  3284.            Unix only.  Causes Edwin to run on Scheme's console, or in Unix 
  3285.            terminology, the standard input and output.  If the console is not a 
  3286.            terminal device, or is not powerful enough to run Edwin, an error 
  3287.            will be signalled at initialization time. 
  3288.  
  3289.  (pm) 
  3290.            OS/2 only.  Creates a Presentation Manager window and uses it as 
  3291.            Edwin's main window. 
  3292.  
  3293.  (win32) 
  3294.            Windows only.  Creates a window and uses it as Edwin's main window. 
  3295.  
  3296.  
  3297. ΓòÉΓòÉΓòÉ 10.2. Leaving Edwin ΓòÉΓòÉΓòÉ
  3298.  
  3299. Once Edwin has been entered, it can be exited in the following ways: 
  3300.  
  3301.  C-x z 
  3302.            Stop Edwin and return to Scheme (suspend-edwin).  The call to the 
  3303.            procedure edit that entered Edwin returns normally.  A subsequent 
  3304.            call to edit will resume Edwin where it was stopped. 
  3305.  
  3306.  C-x c 
  3307.            Offer to save any modified buffers, then kill Edwin, returning to 
  3308.            Scheme (save-buffers-kill-edwin).  This is like the suspend-edwin 
  3309.            command, except that a subsequent call to edit will reinitialize the 
  3310.            editor. 
  3311.  
  3312.  C-x C-z 
  3313.            Stop Edwin and suspend Scheme, returning control to the operating 
  3314.            system's command interpreter (suspend-scheme).  When Scheme is 
  3315.            resumed (using the command interpreter's job-control commands), 
  3316.            Edwin is automatically restarted where it was stopped.  This command 
  3317.            is identical to the C-x C-z command of GNU Emacs. 
  3318.  
  3319.  C-x C-c 
  3320.            Offer to save any modified buffers, then kill both Edwin and Scheme 
  3321.            (save-buffers-kill-scheme).  Control is returned to the operating 
  3322.            system's command interpreter, and the Scheme process is terminated. 
  3323.            This command is identical to the C-x C-c command of GNU Emacs. 
  3324.  
  3325.  
  3326. ΓòÉΓòÉΓòÉ 10.3. Last Resorts ΓòÉΓòÉΓòÉ
  3327.  
  3328. When Scheme exits abnormally it tries to save any unsaved Edwin buffers. The 
  3329. buffers are saved in an auto-save file in case the original is more valuable 
  3330. than the unsaved version.  You can use the editor command M-x recover-file to 
  3331. recover the auto-saved version.  The name used to specify an auto-save file is 
  3332. operating-system dependent: under Unix, and on PC file systems with long file 
  3333. names, `foo.scm' will be saved as `#foo.scm#'; on PC file systems with short 
  3334. file names, it will be saved as `foo.sav'. 
  3335.  
  3336. The following Scheme procedures are useful for recovering from bugs in Edwin's 
  3337. implementation.  All of them are designed for use when Edwin is not running --- 
  3338. they should not be used when Edwin is running. These procedures are designed to 
  3339. help Edwin's implementors deal with bugs during the implementation of the 
  3340. editor; they are not intended for casual use, but as a means of recovering from 
  3341. bugs that would otherwise require reloading the editor's world image from the 
  3342. disk. 
  3343.  
  3344. -- procedure+: save-editor-files 
  3345. Examines Edwin, offering to save any unsaved buffers.  This is useful if some 
  3346. bug caused Edwin to die while there were unsaved buffers, and you want to save 
  3347. the information without restarting the editor. 
  3348.  
  3349. -- procedure+: reset-editor 
  3350. Resets Edwin, causing it to be reinitialized the next time that edit is called. 
  3351. If you encounter a fatal bug in Edwin, a good way to recover is to first call 
  3352. save-editor-files, and then to call reset-editor.  That should completely reset 
  3353. the editor to its initial state. 
  3354.  
  3355. -- procedure+: reset-editor-windows 
  3356. Resets Edwin's display structures, without affecting any of the buffers or 
  3357. their contents.  This is useful if a bug in the display code causes Edwin's 
  3358. internal display data structures to get into an inconsistent state that 
  3359. prevents Edwin from running. 
  3360.  
  3361.  
  3362. ΓòÉΓòÉΓòÉ 11. Release Notes ΓòÉΓòÉΓòÉ
  3363.  
  3364. The last full release of MIT Scheme was version 7.3.1 in 1994.  The first 
  3365. section summarizes the changes that have occurred since version 7.3.1. 
  3366. Following that are changes from previous versions. 
  3367.  
  3368.  
  3369. ΓòÉΓòÉΓòÉ 11.1. Changes from Release 7.3 to 7.4 ΓòÉΓòÉΓòÉ
  3370.  
  3371. This highlights some of the more important changes to Scheme since the 7.3.1 
  3372. release.  For complete details, see the `RCS.log' files in the source code. 
  3373.  
  3374. Changes to Scheme: 
  3375.  
  3376.      MIT Scheme is now supported under OS/2. 
  3377.  
  3378.      Illegally-placed internal definitions now signal an error. 
  3379.  
  3380.      Stream operations from the upcoming new edition of sicp are implemented. 
  3381.  
  3382.      The load-option procedure is now extensible, allowing users to add their 
  3383.       own options to the database. 
  3384.  
  3385.      Daylight-savings-time information is now included in the decoded time 
  3386.       data structure. 
  3387.  
  3388.  Changes to Edwin: 
  3389.  
  3390.      Cut and paste between Edwin and the system's clipboard (in X11, the 
  3391.       "selection" mechanism) is now supported.  This support is directly 
  3392.       integrated into the kill and yank commands: killing some text (e.g. C-w, 
  3393.       C-k, C-M-k) stores that text into the clipboard; yanking text (e.g. C-y, 
  3394.       M-y) inserts text from the clipboard.  This support is transparent in 
  3395.       that it has no effect on Edwin except when some other program puts text 
  3396.       into the clipboard. 
  3397.  
  3398.      Old rcs support has been replaced with vc ("Version Control") as in Emacs 
  3399.       19.  vc is significantly easier to use.  At present, vc supports only 
  3400.       rcs. 
  3401.  
  3402.      New command: M-x step-expression; steps through the evaluation of a 
  3403.       Scheme expression. 
  3404.  
  3405.      New command: M-x grep, as in Emacs. 
  3406.  
  3407.      rmail and Unix mail files are now stored in Unix text format, regardless 
  3408.       of the underlying operating system.  This allows these files to be more 
  3409.       easily transferred between operating systems. 
  3410.  
  3411.      The editor variable evaluate-in-inferior-repl now defaults to #t. 
  3412.  
  3413.      Customizable imaging of characters is now supported.  The per-buffer 
  3414.       variable char-image-strings holds a vector of 256 strings that determine 
  3415.       how characters are displayed.  Using an approriate vector allows the use 
  3416.       of fonts with extra characters, "hex" displays, compound characters for 
  3417.       displaying iso Latin text in plain ascii, and lots of other tricks. 
  3418.  
  3419.      Dired's commands are now more like those in Emacs 19. 
  3420.  
  3421.      Dired mode is no longer case-sensitive. 
  3422.  
  3423.      Dired now supports marking of multiple files.  Many commands, such as M, 
  3424.       C, and R, now work on the marked files if there are any. 
  3425.  
  3426.      New command in Dired: + creates a new directory. 
  3427.  
  3428.      OS/2 and Unix only: Fetching mail from a pop server is now supported, 
  3429.       using the `popclient' program as a subprocess.  Supports three different 
  3430.       `popclient' password schemes: standard, Debian GNU/Linux, and Kerberos 
  3431.       V4.  Do M-x variable-apropos RET pop RET to see the variables that 
  3432.       control the use of the `popclient' program. 
  3433.  
  3434.      OS/2 and Unix only: Compressed files are now fully supported.  Edwin can 
  3435.       read, write, and append compressed files.  Methods are provided to 
  3436.       support the `gzip' and `compress' compression programs, using the 
  3437.       suffixes `.gz' and `.Z', respectively.  If Edwin is attempting to open a 
  3438.       file that doesn't exist, but it sees what appears to be a compressed 
  3439.       version of that file, it opens the compressed file instead. 
  3440.  
  3441.      OS/2 and Unix only: In Dired, s now toggles between alphabetic sorting 
  3442.       and time sorting. 
  3443.  
  3444.  Changes Specific to Windows: 
  3445.  
  3446.      Long filenames are now supported. 
  3447.  
  3448.      The network `\\host\directory' notation is now supported. 
  3449.  
  3450.      Scheme no longer supports the ^Z end-of-file convention for files.  A ^Z 
  3451.       appearing in a file is treated as an ordinary character, and output files 
  3452.       do not have ^Z placed at their end. 
  3453.  
  3454.      The runtime system now has better heuristics for determining the user 
  3455.       name and home directory. 
  3456.  
  3457.      The catatonia timeout has been extended to 120 seconds --- much more 
  3458.       reasonable on slow machines. 
  3459.  
  3460.      Window text color now defaults to the system default rather than to 
  3461.       black. 
  3462.  
  3463.      The default window font family and size is now selectable by the 
  3464.       environment variable `MITSCHEME_FONT'. 
  3465.  
  3466.      process-time-clock now returns the process time, rather than the real 
  3467.       time, under NT or any variant of Win32 that supports GetProcessTimes. 
  3468.  
  3469.      A bug has been fixed in the directory reader in which the OS handle was 
  3470.       never closed.  This was manifested under Windows 3.1 as Edwin being 
  3471.       unable to do filename completion or file saving after 32 handles were 
  3472.       opened but never closed. 
  3473.  
  3474.  Changes Specific to Edwin under Windows: 
  3475.  
  3476.      File systems with either long or short file names are now supported. 
  3477.       Edwin modifies its behavior depending on the file-system type, for 
  3478.       example, using Unix-style `.~n~' backup names with long files. 
  3479.  
  3480.      Multiple Edwin screens are now supported. 
  3481.  
  3482.      The handling of windows has been significantly improved; it is now faster 
  3483.       and less buggy. 
  3484.  
  3485.      New Edwin commands include M-x set-font, M-x set-default-font, M-x 
  3486.       set-icon, M-x set-foreground-color and M-x set-background-color. 
  3487.  
  3488.  Changes Specific to OS/2 (since the 7.4.1 release): 
  3489.  
  3490.      The main console window now supports a Copy command.  Any text appearing 
  3491.       on the window can be copied to the clipboard by marking it with the mouse 
  3492.       and invoking the Copy command. 
  3493.  
  3494.      The main console window now has a menu bar, which provides the following 
  3495.       operations: Exit, Copy, Paste, Set font, and About. 
  3496.  
  3497.      The main console window now has a list of fonts that it tries to use to 
  3498.       set the default font, rather than just "4.System VIO".  It tries these 
  3499.       fonts in order until it finds one.  This allows Scheme to be used on 
  3500.       systems that don't support the `System VIO' font, as is true of some 
  3501.       non-US versions of OS/2. 
  3502.  
  3503.      Closing the main console window using the window Close command now asks 
  3504.       whether you want to kill Scheme or just close the window and leave Scheme 
  3505.       running; usually you will want the former.  Previously, it did the latter 
  3506.       without asking. 
  3507.  
  3508.      All windows created by Scheme now have icons to give them a distinctive 
  3509.       appearance when minimized. 
  3510.  
  3511.      Compilation of the microcode is supported using IBM Visual Age C++, 
  3512.       Watcom C/C++, or emx/gcc. 
  3513.  
  3514.      Unix file systems are supported specially, e.g. Linux ext2 or Unix nfs. 
  3515.       End-of-line translation is not done for files on such file systems, so 
  3516.       that the files are read and written properly. 
  3517.  
  3518.      The network `\\host\directory' notation is now supported. 
  3519.  
  3520.  Changes Specific to Edwin under OS/2: 
  3521.  
  3522.      The Close command on the window menu of an Edwin window now acts like C-x 
  3523.       C-c if this is the only Edwin window for this process. 
  3524.  
  3525.      In Dired, S now toggles between showing and hiding system/hidden files; 
  3526.       these files are initially hidden. 
  3527.  
  3528.      Dired has an M command to set the attributes of a file.  It prompts for 
  3529.       an attribute string such as `+r' or `-h' and makes the corresponding 
  3530.       change to the file's attributes. 
  3531.  
  3532.  
  3533. ΓòÉΓòÉΓòÉ 11.2. Changes from Release 7.2 to 7.3 ΓòÉΓòÉΓòÉ
  3534.  
  3535. This is an abbreviated list of the changes that have been incorporated in the 
  3536. 7.3 release since the (partial) 7.2 release. 
  3537.  
  3538.      Support for MS Windows (3.1 and NT). 
  3539.  
  3540.      Native compiled-code support for DEC Alpha. 
  3541.  
  3542.      Compiler can now generate C code.  This is used to support the Sun SPARC 
  3543.       and IBM RS6000 architectures. 
  3544.  
  3545.      Support for dynamic loading of compiled C code on several operating 
  3546.       systems, including HP-UX, OSF/1, SunOS 4, and AIX. 
  3547.  
  3548.      New data structures: red/black trees and weight-balanced trees. 
  3549.  
  3550.      Redesign of hash tables makes them much faster and somewhat more 
  3551.       flexible. 
  3552.  
  3553.      Completely new random-number generator.  The interface to the 
  3554.       random-number generator has been changed to be like that of Common Lisp. 
  3555.  
  3556.      Record abstraction now uses a special record type to represent records 
  3557.       (previously it used vectors).  define-structure now creates records by 
  3558.       default; these records are identical to those created with the record 
  3559.       abstraction. 
  3560.  
  3561.      call-with-current-continuation is now properly tail-recursive. 
  3562.  
  3563.      New command-line switch `-no-suspend-file' prevents the generation of 
  3564.       `scheme_suspend' files. 
  3565.  
  3566.      Uncompression of compiled-code debugging information is now memoized to 
  3567.       save time when doing many accesses to the same information (a common 
  3568.       occurrence). 
  3569.  
  3570.      Constant space now grows automatically when needed. 
  3571.  
  3572.      New procedures: 
  3573.  
  3574.             call-with-values                ;replaces with-values
  3575.             current-load-pathname
  3576.             error-output-port
  3577.             fold-left
  3578.             fold-right
  3579.             interaction-i/o-port
  3580.             notification-output-port
  3581.             prompt-for-command-char
  3582.             prompt-for-command-expression
  3583.             prompt-for-confirmation
  3584.             prompt-for-evaluated-expression
  3585.             prompt-for-expression
  3586.             standard-unparser-method        ;replaces unparser/standard-method
  3587.             stream-first
  3588.             stream-rest
  3589.             symbol<?
  3590.             trace-output-port
  3591.  
  3592.      string-pad-left now truncates from the left instead of the right. 
  3593.  
  3594.      Argument to make-graphics-device is now a symbol. 
  3595.  
  3596.      Each repl now has its own working directory pathname and pathname 
  3597.       defaults.  set-working-directory-pathname! changes only the value for the 
  3598.       current repl. 
  3599.  
  3600.      The definitions of the following procedures have been changed to 
  3601.       implement more useful behavior: 
  3602.  
  3603.             string-capitalized?
  3604.             string-lower-case?
  3605.             string-upper-case?
  3606.             substring-capitalized?
  3607.             substring-lower-case?
  3608.             substring-upper-case?
  3609.  
  3610.      New Edwin features: 
  3611.  
  3612.             M-x dabbrev-expand
  3613.             M-x describe-syntax
  3614.             M-x rcs-ci-locked-files
  3615.             M-x rcs-diff
  3616.             M-x rcs-list-locked-files
  3617.             M-x rcs-log
  3618.             M-x recover-file
  3619.             M-x show-parameter-list
  3620.             M-x sort-lines and other sorting commands
  3621.             auto-mode-alist variable (as in Emacs)
  3622.             Encryption/decryption of files in Dired
  3623.             Undo upgraded to match GNU Emacs 18.57
  3624.             Buffers grow/shrink with constant amortized time
  3625.             Emacs 19 tags support (multiple tags files, inclusion)
  3626.  
  3627.      Edwin compression/uncompression commands changed to use gzip instead of 
  3628.       compress. 
  3629.  
  3630.      Edwin now has text-properties mechanism that permits implementation of 
  3631.       highlighted and mouse-sensitive regions. 
  3632.  
  3633.  
  3634. ΓòÉΓòÉΓòÉ 11.3. Changes from Release 7.1 to 7.2 ΓòÉΓòÉΓòÉ
  3635.  
  3636. This is an abbreviated list of the changes that were incorporated in the 
  3637. (partial) 7.2 release since the 7.1 release. 
  3638.  
  3639.      Support for MS DOS. 
  3640.  
  3641.      Native compiled-code support for the Intel i386 and i486 architectures. 
  3642.  
  3643.      Fixes to MIPS compiled-code support MIPS R3000 with large cache-line 
  3644.       sizes. 
  3645.  
  3646.      Complete redesign of the error system. 
  3647.  
  3648.      X11 graphics interface redesigned.  The new design is smarter about 
  3649.       interaction with the window manager (for example, it implements the 
  3650.       WM_DELETE_WINDOW protocol) and has some limited support for event 
  3651.       handling.  Windows are now closed when they are reclaimed by the garbage 
  3652.       collector. 
  3653.  
  3654.      Redesign of i/o ports.  New design supports ports that perform both input 
  3655.       and output. 
  3656.  
  3657.      Ports now have better-defined control over blocking mode and terminal 
  3658.       mode.  Flushing of output buffers is not done automatically, except for 
  3659.       the console port. 
  3660.  
  3661.      New procedures: 
  3662.  
  3663.             *default-pathname-defaults*
  3664.             ->namestring
  3665.             ->truename
  3666.             close-port
  3667.             directory-namestring
  3668.             directory-pathname
  3669.             directory-pathname-as-file
  3670.             enough-namestring
  3671.             enough-pathname
  3672.             file-access
  3673.             file-attributes-direct          ;same as file-attributes
  3674.             file-modification-time-direct
  3675.             file-modification-time-indirect ;same as file-modification-time
  3676.             file-namestring
  3677.             file-pathname
  3678.             file-readable?
  3679.             host-namestring
  3680.             i/o-port?
  3681.             make-generic-i/o-port
  3682.             make-i/o-port
  3683.             open-i/o-file
  3684.             pathname-simplify
  3685.             pathname-wild?
  3686.             pathname=?
  3687.             port/copy
  3688.             port/input-channel
  3689.             port/operation
  3690.             port/operation-names
  3691.             port/output-channel
  3692.             port/state
  3693.             port?
  3694.             record-copy
  3695.             record-modifier                 ;replaces record-updater
  3696.             set-port/state!
  3697.  
  3698.      with-input-from-file and with-output-to-file no longer close the port 
  3699.       when they are exited abnormally. 
  3700.  
  3701.      Redefined #!optional and #!rest to be something distinct from symbols. 
  3702.  
  3703.      Strings now accept "\nnn" octal character escapes, much like those in C. 
  3704.  
  3705.      Redesign of pathname abstraction.  New design is very similar to the 
  3706.       Common Lisp pathname abstraction. 
  3707.  
  3708.         -  ->PATHNAME no longer accepts a symbol as an argument.  Only strings 
  3709.            and pathnames are valid. 
  3710.  
  3711.         -  Procedures eliminated: 
  3712.  
  3713.                       canonicalize-input-filename
  3714.                       canonicalize-input-pathname
  3715.                       canonicalize-output-filename
  3716.                       canonicalize-output-pathname
  3717.                       canonicalize-overwrite-filename
  3718.                       canonicalize-overwrite-pathname
  3719.                       home-directory-pathname
  3720.                       init-file-truename
  3721.                       pathname->absolute-pathname
  3722.                       pathname->input-truename
  3723.                       pathname->output-truename
  3724.                       pathname->overwrite-truename
  3725.                       pathname->string
  3726.                       pathname-components
  3727.                       pathname-default-host
  3728.                       pathname-directory-path
  3729.                       pathname-directory-string
  3730.                       pathname-name-path
  3731.                       pathname-name-string
  3732.                       pathname-new-host
  3733.                       pathname-relative?
  3734.                       string->pathname
  3735.                       symbol->pathname
  3736.  
  3737.         -  pathname-default no longer accepts a host argument. 
  3738.  
  3739.         -  Representation of pathname directories changed to match Common Lisp. 
  3740.            Directory is now either #f or a list of symbols and strings with 
  3741.            first element either absolute or relative. 
  3742.  
  3743.         -  Unix pathnames now set device and version to unspecific.  unspecific 
  3744.            now means that the field is not used by the operating system. 
  3745.  
  3746.         -  Parsing rules for Unix filenames changed: the file type is the part 
  3747.            of the name after the last dot, if any.  If the dot occurs at the 
  3748.            beginning or end of the filename, then it doesn 't count --- in that 
  3749.            case there is no type.  Thus, names like `.' and `..' have no type. 
  3750.  
  3751.      New Edwin features: 
  3752.  
  3753.             M-x manual-entry
  3754.             M-x outline-mode
  3755.             M-x shell-resync-dirs
  3756.             M-x shell-command
  3757.             M-x shell-command-on-region
  3758.             M-x telnet
  3759.             rmail summary
  3760.             rmail sort
  3761.             repl mode and asynchronous evaluation
  3762.             Printing commands
  3763.             "run light" for evaluation commands
  3764.             Reading and writing of compressed files (".Z" suffix)
  3765.             Reading and writing of encrypted files (".KY" suffix)
  3766.             Compress/uncompress commands for Dired
  3767.             Support for X protocols: WM_DELETE_WINDOW and WM_TAKE_FOCUS
  3768.             Time, load, and mail notification in mode line
  3769.  
  3770.  
  3771. ΓòÉΓòÉΓòÉ 12. Comparison of Edwin to Emacs ΓòÉΓòÉΓòÉ
  3772.  
  3773. This section documents known differences between Edwin 3.90 and Emacs 18.57.  A 
  3774. reference to a "documented" feature of Emacs means that the feature is 
  3775. documented in the GNU Emacs version 18 manual. 
  3776.  
  3777.  
  3778. ΓòÉΓòÉΓòÉ 12.1. Incompatibilities ΓòÉΓòÉΓòÉ
  3779.  
  3780. These are differences in design, unlikely to be `fixed'. 
  3781.  
  3782.      Edwin's keyboard character set is a superset of Emacs'.  Edwin has 
  3783.       support for real MIT-style bucky bits.  Under X windows and OS/2 (and 
  3784.       perhaps other systems) Edwin can distinguish between C-a and C-A, C-SPC 
  3785.       and C-@, etc.  When running on a terminal, the input set is limited to 
  3786.       8-bit ascii as in Emacs. 
  3787.  
  3788.      Edwin is case-insensitive for command and variable names. 
  3789.  
  3790.      Edwin additionally defines C-z and C-^ as prefix keys. C-z is the 
  3791.       CTRL-META prefix, and C-^ is the CTRL prefix, both as in TOPS-20 Emacs. 
  3792.  
  3793.      C-z doesn't suspend Edwin.  C-x C-z suspends both Emacs and Edwin, but 
  3794.       isn't defined in the Emacs Manual.  Under X, Emacs produces an error 
  3795.       message when C-x C-z is typed; Edwin suspends itself if it was started 
  3796.       from a shell with job control, otherwise it dies. 
  3797.  
  3798.      C-h f doesn't work for anything but editor commands, i.e. it only 
  3799.       documents editor commands, not ordinary Scheme procedures like car or 
  3800.       call-with-current-continuation. 
  3801.  
  3802.      C-h v doesn't work for anything but editor variables, i.e. it only 
  3803.       documents editor variables, not ordinary Scheme variables. 
  3804.  
  3805.      In Edwin, C-w and C-y don't skip to next occurrence in reverse i-search. 
  3806.       This is intentional, and matches the behavior of Emacs 19. 
  3807.  
  3808.      comment-indent-hook is defined differently.  In Emacs, it is called with 
  3809.       no arguments and with point at the beginning of the comment; in Edwin, it 
  3810.       is called with a single argument, the mark at the beginning of the 
  3811.       comment, and with point undefined. 
  3812.  
  3813.      Edwin's completion of Scheme variables is dependent on the environment. 
  3814.       In Scheme and Scheme Interaction modes, M-TAB completes the Scheme 
  3815.       variable name.  Completion is environment-dependent, so a prefix may 
  3816.       complete differently (or not at all) in two different buffers with 
  3817.       different associated environments. 
  3818.  
  3819.      M-x load-file and M-x load-library behave somewhat differently in Edwin. 
  3820.  
  3821.      The evaluation commands are much different in Edwin. 
  3822.  
  3823.      Edwin doesn't recognize `Local Variables:' at the end of a file; instead 
  3824.       it recognizes `Edwin Variables:'.  This is done because it cannot support 
  3825.       the full syntax of Emacs local variables. 
  3826.  
  3827.      Variable text-mode-hook is an event distributor rather than a procedure 
  3828.       of no arguments. 
  3829.  
  3830.  
  3831. ΓòÉΓòÉΓòÉ 12.2. Deficiencies ΓòÉΓòÉΓòÉ
  3832.  
  3833. Deficiencies are shortcomings of Edwin that are likely to be fixed. 
  3834.  
  3835.      C-x ^ can be used to grow or shrink the minibuffer window in Emacs but 
  3836.       not in Edwin. 
  3837.  
  3838.      C-h in Edwin is a subset of that in Emacs. Missing subcommands: 
  3839.  
  3840.             n   view-emacs-news
  3841.             c-c describe-copying
  3842.             c-d describe-distribution
  3843.             c-w describe-warranty
  3844.  
  3845.      Dired is missing these commands in Edwin: v and B. 
  3846.  
  3847.      C-x n is not disabled by default. 
  3848.  
  3849.      Edwin does not have the notion of "novice". 
  3850.  
  3851.  
  3852. ΓòÉΓòÉΓòÉ 12.3. Missing Subsystems ΓòÉΓòÉΓòÉ
  3853.  
  3854. The following documented subsystems are implemented by Emacs but not by Edwin. 
  3855.  
  3856.      abbrev mode (edwin has dynamic abbreviations) 
  3857.  
  3858.      emulation modes: edt, vi, vip 
  3859.  
  3860.      file locks 
  3861.  
  3862.      language modes: emacs-lisp, fortran, lisp, modula-2, prolog 
  3863.  
  3864.      overwrite mode 
  3865.  
  3866.      picture mode 
  3867.  
  3868.      slow terminal incremental search 
  3869.  
  3870.      spelling 
  3871.  
  3872.      tab stops 
  3873.  
  3874.      text formatter modes: nroff, scribe, tex, latex 
  3875.  
  3876.  
  3877. ΓòÉΓòÉΓòÉ 12.4. Missing Commands ΓòÉΓòÉΓòÉ
  3878.  
  3879. These commands are implemented by Emacs but not by Edwin.  The commands marked 
  3880. with an asterisk are implemented under Unix and OS/2 but not under Windows. 
  3881. Some of the asterisked commands can work under Windows but the code to 
  3882. implement them is not loaded in order to save space; others are require 
  3883. subprocess support that isn't available in the Windows implementation. 
  3884.  
  3885.   abbrev-mode
  3886.   abbrev-prefix-mark
  3887.   add-change-log-entry
  3888.   add-change-log-entry-other-window
  3889.   add-global-abbrev
  3890.   add-mode-abbrev
  3891.   add-name-to-file
  3892.   append-to-buffer
  3893.   byte-compile-file
  3894.   byte-recompile-directory
  3895.   cancel-debug-on-entry
  3896. * compile
  3897.   convert-mocklisp-buffer
  3898.   copy-to-buffer
  3899.   debug-on-entry
  3900.   define-abbrevs
  3901. * delete-matching-lines
  3902. * delete-non-matching-lines
  3903.   describe-copying
  3904.   describe-distribution
  3905.   describe-no-warranty
  3906.   describe-syntax
  3907.   disable-command
  3908.   disassemble
  3909.   display-time                          (run-notifier is similar)
  3910.   dissociated-press
  3911.   doctor
  3912.   edit-abbrevs
  3913.   edit-abbrevs-redefine
  3914.   edit-options
  3915.   edit-picture
  3916.   edit-tab-stops
  3917.   edit-tab-stops-note-changes
  3918.   edt-emulation-on
  3919.   emacs-lisp-mode
  3920.   emacs-version
  3921.   enable-command
  3922.   expand-abbrev
  3923.   expand-region-abbrevs
  3924.   flush-lines
  3925.   fortran-mode
  3926.   global-set-key                        (set-key is similar)
  3927.   grep
  3928.   hanoi
  3929.   indent-c-exp                          c-indent-expression
  3930.   insert-abbrevs
  3931.   insert-kbd-macro                      write-kbd-macro
  3932.   insert-parentheses
  3933.   inverse-add-global-abbrev
  3934.   inverse-add-mode-abbrev
  3935. * keep-lines
  3936.   kill-all-abbrevs
  3937.   latex-mode                            Note: BAL has one
  3938.   lisp-complete-symbol                  (scheme-complete-variable is similar)
  3939.   lisp-interaction-mode                 (inferior-repl-mode is similar)
  3940.   lisp-mode
  3941.   lisp-send-defun
  3942.   list-abbrevs
  3943.   list-command-history
  3944.   list-options
  3945.   list-tags
  3946.   local-set-key
  3947. * lpr-buffer
  3948. * lpr-region
  3949.   make-symbolic-link
  3950.   make-variable-buffer-local
  3951. * manual-entry
  3952.   modify-syntax-entry
  3953.   move-past-close-and-reindent
  3954.   next-error
  3955.   next-file
  3956.   nroff-mode
  3957. * occur
  3958. * occur-mode-goto-occurrence
  3959.   open-dribble-file
  3960.   open-termscript
  3961.   overwrite-mode
  3962.   plain-tex-mode
  3963.   prepend-to-buffer
  3964. * print-buffer
  3965. * print-region
  3966.   read-abbrev-file
  3967.   recover-file
  3968.   run-lisp
  3969.   save-buffers-kill-emacs               save-buffers-kill-scheme
  3970.   set-gosmacs-bindings
  3971. * shell-command
  3972. * shell-command-on-region
  3973.   spell-buffer
  3974.   spell-region
  3975.   spell-string
  3976.   spell-word
  3977.   suspend-emacs                         suspend-scheme
  3978.   tab-to-tab-stop
  3979.   tags-apropos
  3980.   tex-mode
  3981.   top-level
  3982.   unexpand-abbrev
  3983.   vi-mode
  3984.   view-buffer
  3985.   view-emacs-news
  3986.   view-file
  3987.   vip-mode
  3988.   write-abbrev-file
  3989.   yow
  3990.   zap-to-char
  3991.  
  3992.  
  3993. ΓòÉΓòÉΓòÉ 12.5. Missing Variables ΓòÉΓòÉΓòÉ
  3994.  
  3995. These documented variables are implemented by Emacs but not Edwin.  The 
  3996. variables marked with an asterisk are implemented under Unix and OS/2, but not 
  3997. under Windows. 
  3998.  
  3999.   abbrev-all-caps
  4000.   abbrev-file-name
  4001.   blink-matching-paren
  4002.   blink-matching-paren-distance
  4003.   buffer-read-only
  4004.   c-tab-always-indent
  4005.   comment-start-skip
  4006. * compile-command
  4007.   completion-ignore-case                (not documented)
  4008.   ctl-arrow
  4009.   debug-on-error                        debug-on-editor-error
  4010.                                         debug-on-internal-error
  4011.                                         debug-on-evaluation-error
  4012.                                         are similar, but more specific
  4013.   debug-on-quit
  4014.   default-directory
  4015.   default-major-mode
  4016.   echo-keystrokes
  4017.   initial-major-mode                    Scheme variable initial-buffer-mode
  4018.   insert-default-directory
  4019.   inverse-video
  4020.   kill-ring-max
  4021.   load-path
  4022. * lpr-switches
  4023.   major-mode
  4024.   mark-ring
  4025.   mark-ring-max                         mark-ring-maximum
  4026.   meta-flag
  4027.   no-redraw-on-recenter
  4028.   save-abbrevs
  4029.   selective-display-ellipses
  4030. * shell-file-name
  4031.   tab-stop-list
  4032.   tags-file-name                        (tags-table-pathnameis similar)
  4033.   track-eol
  4034.   visible-bell
  4035.  
  4036.  
  4037. ΓòÉΓòÉΓòÉ 12.6. Per-Buffer Variables ΓòÉΓòÉΓòÉ
  4038.  
  4039. These documented variables are per-buffer in Emacs but not in Edwin. 
  4040.  
  4041. abbrev-mode
  4042. auto-fill-hook
  4043. buffer-auto-save-file-name
  4044. buffer-backed-up
  4045. buffer-file-name
  4046. buffer-offer-save
  4047. buffer-read-only
  4048. buffer-saved-size
  4049. buffer-undo-list
  4050. ctl-arrow
  4051. default-directory
  4052. local-abbrev-table
  4053. major-mode
  4054. mark-ring
  4055. mode-name
  4056. overwrite-mode
  4057. selective-display
  4058. selective-display-ellipses
  4059. shell-prompt-pattern
  4060.  
  4061.  
  4062. ΓòÉΓòÉΓòÉ 12.7. Edwin Bugs ΓòÉΓòÉΓòÉ
  4063.  
  4064. Incorrect behavior of Edwin that will be fixed: 
  4065.  
  4066.      Negative argument to M-u, M-l, and M-c seems to work by accident. 
  4067.  
  4068.      `-*- foo -*-' is valid if preceded only by blank lines; in Edwin this 
  4069.       works only if it is on a file's the first line. 
  4070.  
  4071.      Closing paren doesn't check for mismatched delimiters and issue warning 
  4072.       message.  In c-mode, `]' isn't treated specially, and don't flash the 
  4073.       matching delimiter. 
  4074.  
  4075.      C-u C-x ; isn't handled right in Edwin. 
  4076.  
  4077.      M-x indent-for-comment shouldn't reindent existing comment in column 
  4078.       zero. 
  4079.  
  4080.  
  4081. ΓòÉΓòÉΓòÉ 13. Index ΓòÉΓòÉΓòÉ
  4082.  
  4083. Sorry, no cp index