home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-26 | 12.7 KB | 341 lines | [TEXT/KAHL] |
- MacGambit v2.0 documentation
- ----------------------------
-
- MacGambit is distributed "AS IS" with NO warranties, either
- expressed or implied.
-
- Bug reports should be sent to: gambit@trex.iro.umontreal.ca
-
-
- Building the MacGambit System
- -----------------------------
-
- The system is distributed in two compressed auto-extracting files:
-
- macgambit-2.0-sources1.sea
- macgambit-2.0-sources2.sea
-
- The first file contains all you need to build the MacGambit interpreter
- and compiler with THINK C 5.0. The second file contains the Scheme source
- files to the runtime and compiler and also the files needed to build
- DEC's Thomas system (a Dylan lookalike).
-
- The first thing you should do is extract the files to your hard disk.
- You need about 5 megs of free disk space. Create a folder, say "MacGambit",
- and put the two compressed files in it. Then, uncompress these
- files by double-clicking them.
-
- To build the MacGambit interpreter and/or compiler, you should follow the
- instructions in sections A and B below. Instructions on how to add access
- to Toolbox (or C) procedures are given in section C below. The compiler and
- linker are explained in section D and E. Open the file "OPEN ME FIRST!" in
- the "Examples" folder to get more information on using the MacGambit
- interpreter.
-
- Read the file "Thomas.README" in the folder "Thomas" for details on
- building the Thomas interpreter.
-
-
- A. Overview
- -----------
-
- MacGambit is built in three steps:
-
- 1) The file "Runtime.π.rsrc" must be created. This file contains some
- resources and the parts of the runtime written in Scheme.
-
- 2) The file "Runtime" must be created. This file contains all of
- "Runtime.π.rsrc" plus the parts of the runtime written in C.
-
- 3) The interpreter and compiler (or any other Scheme program) is linked
- with the "Runtime" file to produce a standalone application.
-
- Note: the first two steps can be skipped by using the prebuilt "Runtime"
- file that comes with the system.
-
-
- B. Building MacGambit
- ---------------------
-
- STEP 1: Creating "Runtime.π.rsrc"
-
- Make sure you have all of the following files and folders, and that
- they are all in the same folder:
- - The application "MacGambit Linker"
- - The folder "Runtime (.O)"
- - The file "Empty Runtime.π.rsrc"
- - The file "Link 'Runtime.π.rsrc'"
-
- Simply double click the file "Link 'Runtime.π.rsrc'".
-
- Note: The Scheme source files to the runtime are in the folder
- "Runtime (.scm & .s)".
-
- STEP 2: Creating "Runtime"
-
- Make sure you have all of the following files and folders, and that
- they are all in the same folder:
- - The file "Runtime.π.rsrc" created in the first step
- - The THINK C 5.0 project file "Runtime.π"
- - The folder "Runtime (.c & .h)"
-
- i) Open the project "Runtime.π" with THINK C (just double click on
- "Runtime.π").
-
- ii) Compile the project by selecting "Make..." in the "Source" menu.
-
- iii) Select "Build application..." from the "Project" menu. Use the name
- "Runtime" as the application name. The resources from the file
- "Runtime.π.rsrc" will automatically be transferred to "Runtime" at
- this point.
-
- STEP 3: Building "MacGambit Interpreter" and/or "MacGambit Compiler"
-
- Make sure you have all of the following files and folders, and that
- they are all in the same folder:
- - The application "MacGambit Linker"
- - The file "Runtime" created in the second step
- - The file "Online Help"
- - The folder "Interpreter (.O)"
- - The folder "Compiler (.O)"
- - The file "Link 'MacGambit Interpreter'" or "Link 'MacGambit Compiler'".
-
- i) If you want the online help system, duplicate the file "Online Help"
- and rename it to "MacGambit Interpreter" (or "MacGambit Compiler" if
- you are building the compiler). Otherwise, make sure that there
- is no file with that name in the folder.
-
- ii) Double click the file "Link 'MacGambit Interpreter'" (or "Link
- 'MacGambit Compiler'").
-
- iii) Note that the system is distributed with a prebuilt version of the
- interpreter. If you want the icon to appear and would like to be
- able to automatically open the interpreter when you double click
- ".scm" and ".O" files, you should do following:
-
- Using ResEdit (or similar program), you should change the creator
- of "MacGambit Interpreter" to "gamI" and set the bundle bit. Also,
- you should copy the following resources from the prebuilt "MacGambit
- Interpreter" into the newly created one:
-
- ICN# BNDL FREF gamI
-
- Alternatively, you can put these resources once and for all
- in the file "Empty Runtime.π.rsrc" before doing step 1.
-
-
- C. Adding Toolbox access to the MacGambit Interpreter
- -----------------------------------------------------
-
- Access to the Toolbox (or other C procedures) can be added to the
- interpreter by modifying the file "ext_mac.c" in the folder "Runtime
- (.c & .h)". A major problem in interfacing C and Scheme is that they do
- not use the same representation for data. Also, C created data
- structures can not be garbage collected. Similarly, the address of
- Scheme objects can change after any garbage collection (so it is not safe
- for C code to keep pointers to memory allocated objects and expect them
- to always be valid). An example of an interface that implements some
- Quickdraw primitives is given in "ext_mac.c". The Scheme file
- "ext_mac.scm" in the folder "Runtime (.scm & .s)" provides procedures
- to access these extensions, it is linked in the normal runtime.
-
-
- D. Using the MacGambit Compiler
- -------------------------------
-
- The MacGambit Compiler (GSC for short) is used to compile a Scheme source
- program into a binary `object file' that can either be loaded by the
- MacGambit Interpreter or turned into a full fledged Macintosh application
- with the MacGambit Linker.
-
- GSC needs at least 2.5 Megs of RAM to run. A larger memory size is
- recommended to compile large Scheme programs. If you do not have enough
- memory to compile a given program, split it into smaller files. Under
- Multifinder, you can adjust the amount of RAM used by GSC by setting
- the "application suggested memory size" using the finder's "Get info..."
- menu. The default is to use 2 Megs under Multifinder or the entire
- memory if you are using the Finder (with a system older than system7).
-
- GSC is almost identical to the interpreter except that it has the
- additional procedure `compile-file' (which can also be accessed through the
- "Compile..." item in the Special menu). The `compile-file' procedure takes
- one or more arguments. The first argument is the name of the file to
- compile. The other arguments are compilation options. For example,
- the call
-
- (compile-file "foo" 'asm)
-
- compiles the file "foo.scm" and produces the assembly file "foo.asm".
- These options are accepted by GSC:
-
- verbose Generate a trace of the compiler's actions on
- the interaction window.
-
- report Produce global variable usage report on the
- interaction window. Each global variable used in
- the program is listed with 4 flags that indicate if
- the global variable is defined, referenced, mutated
- and called.
-
- asm Produce the assembly language file on <source>.asm .
-
- pvm Produce a listing of the PVM code for the program
- on <source>.pvm .
-
- debug Generate code that contains debugging information to aid
- debugging with the interpreter.
-
-
- In addition to the standard Scheme special forms, the compiler accepts
- the following forms which can appear anywhere a `define' special form
- can appear:
-
- (##declare <decl>...)
-
- See below for the list of accepted declarations.
- The scope of the declaration extends to the end of the body it is in
- or to the end of the program if it is at toplevel.
-
- (##include "prog.scm")
-
- Read the expressions contained in the given file and splice them
- into the program.
-
- (##define-macro (name parm...) <body>)
-
- Define the name as a macro special form which expands into `body'.
- The scope of the declaration extends to the end of the body it is in
- or to the end of the program if it is at toplevel.
-
-
- The following declarations are accepted by the compiler:
-
- (<dialect>)
-
- Use the given dialect's semantics. <dialect> can be:
- ieee-scheme, r4rs-scheme or multilisp. Note that MacGambit does not
- yet implement the high-level macro facility defined in R4RS Scheme.
-
- ([not] lambda-lift)
-
- Lambda-lift (or don't lambda-lift) procedures.
-
- (<strategy>)
-
- Select block compilation or separate compilation. In block
- compilation, the compiler can assume that all references to the
- global variables defined in the current program are located in the
- program itself. <strategy> can be: block or separate.
-
- ([not] standard-bindings <var>...)
-
- The given global variables are known (or not known) to be equal
- to the value defined for them in the dialect (all variables defined
- in the standard if none specified).
-
- ([not] extended-bindings <var>...)
-
- The given global variables are known (or not known) to be equal
- to the value defined for them in the runtime system (all variables
- defined in the runtime if none specified).
-
- ([not] safe)
-
- Generate (or don't generate) code that will prevent fatal runtime
- errors. Note that in `safe' mode certain semantic errors will not be
- checked as long as they can't crash the system. For example
- the primitive `char=?' could disregard the type of its arguments in
- `safe' (as well as `not safe') mode.
-
- ([not] intr-checks)
-
- Generate (or don't generate) interrupt checks. Interrupt checks are
- used to signal the need for a garbage collection, to catch user
- interrupts and also to check for stack overflows. Interrupt checking
- should not be turned off casually.
-
- (<number-type> <prim>...)
-
- Numeric arguments and result of specified primitives are known to be
- of the given type (all primitives if none specified).
- <number-type> can be: generic or fixnum.
-
-
- The default declarations used by the compiler are:
-
- (ieee-scheme)
- (lambda-lift)
- (separate)
- (not standard-bindings)
- (not extended-bindings)
- (not safe)
- (intr-checks)
- (generic)
-
- These declarations are compatible with the IEEE-Scheme standard.
- Typically used declarations that enhance performance (at the cost of
- violating the IEEE-Scheme standard) are: (standard-bindings) and
- (fixnum).
-
- The diagnostic messages produced by GSC are printed on the interaction
- window. When the compiler detects an error, it pops up a window with
- the erroneous source file and highlights the location of the error.
-
- The code generated by GSC is very efficient. Speedups of a factor of 100
- over interpreted code are not uncommon.
-
-
- A useful feature of object files is that they can be run by
- double-clicking them. This is essentially equivalent to starting the
- interpreter and loading the given object file (except that the
- "init.scm" file is not loaded and a read-eval-print loop is not entered).
-
- As an example, compile the file "pi.scm" producing the object file
- "pi.O". Now, quit the compiler and double-click the file "pi.O". This
- will run the program. Note that when "pi.scm" logically terminates
- execution, the interpreter also exits.
-
-
- E. Using the MacGambit Linker
- -----------------------------
-
- The MacGambit linker is used to build a Macintosh application program
- from a runtime library and a certain number of object files produced by
- the MacGambit compiler (there is an upper limit of 64 object files). The
- files to be linked can either be entered interactively or with a
- "link script".
-
- Interactive use:
- The MacGambit linker first prompts for the runtime library file (you
- should normally use `Runtime') and then for a set of object files. The
- name of the application is the same as the name of the last object file
- to be linked with its `.O' file extension stripped off.
-
- With a "link script":
- A link script is a file containing the names of the files to link (one name
- per line). The first line contains the name of the runtime library file.
- The following lines name the object files. In addition, the name of the
- application can be specified by putting it at the end of the script, after
- a blank line.
-
- When the linked program is launched, the effect is similar to loading
- each of the object files, in sequence, in the interpreter (except that
- the "init.scm" file is not loaded and a read-eval-print loop is not entered
- (unless of course you link in the object file "mac_toplevel.O" in the folder
- "Interpreter (.O)"))).
-
- Linking examples:
-
- 1) link the library "Runtime" with the object file "pi.O" to get the
- application "pi". Note that when "pi.scm" logically terminates,
- the program exits to the finder.
-
- 2) link the library "Runtime" with the object files "queens.O" and
- "mac_toplevel.O" to add the procedure "queens" to the interpreter.
-
-
- Distribution restrictions
- -------------------------
-
- Read the "About MacGambit" dialog box.
-