XEROX PSEUDOSCHEME 2 4 1 PSEUDOSCHEME 1 4 By: JAR@AI.AI.MIT.EDU This document last edited on 28 January 87 by Larry Masinter (Masinter.pa@Xerox.com). INTRODUCTION PSEUDOSCHEME is a simple package intended to allow you to run certain Scheme programs in any Common Lisp implementation (including the Xerox 1100 series). If you start using PSEUDOSCHEME, please send mail to JAR@AI.AI.MIT.EDU (Arpanet address) so that you can be kept up to date on developments. There's a mailing list INFO-CLSCH@MC for people who are interested in this kind of thing. ;;; Copyright (c) 1986 Massachusetts Institute of Technology ;;; ;;; This material was developed by the Scheme project at the ;;; Massachusetts Institute of Technology, Department of ;;; Electrical Engineering and Computer Science. Permission to ;;; copy this software, to redistribute it, and to use it for any ;;; purpose is granted, subject to the following restrictions and ;;; understandings. ;;; ;;; 1. Any copy made of this software must include this copyright ;;; notice in full. ;;; ;;; 2. Users of this software agree to make their best efforts (a) ;;; to return to the MIT Scheme project any improvements or ;;; extensions that they make, so that these may be included in ;;; future releases; and (b) to inform MIT of noteworthy uses of ;;; this software. ;;; ;;; 3. All materials developed as a consequence of the use of ;;; this software shall duly acknowledge such use, in accordance ;;; with the usual standards of acknowledging credit in academic ;;; research. ;;; ;;; 4. MIT has made no warrantee or representation that the ;;; operation of this software will be error-free, and MIT is ;;; under no obligation to provide any services, by way of ;;; maintenance, update, or otherwise. ;;; ;;; 5. In conjunction with products arising from the use of this ;;; material, there shall be no use of the name of the ;;; Massachusetts Institute of Technology nor of any adaptation ;;; thereof in any advertising, promotional, or sales literature ;;; without prior written consent from MIT in each case. To use PSEUDOSCHEME: Load the module PSEUDOSCHEME.DFASL from your LispUsers directory. In a (new) Exec window, type (IN-PACKAGE "SCHEME") If using TEdit, insert the following two lines at the beginning of each of your Scheme source files: (in-package 'scheme :use '(pseudoscheme)) Now you're ready to go; treat Scheme code exactly as if it were Lisp code. You can use LOAD and COMPILE-FILE on files of Scheme code, and the regular Exec will let you evaluate Scheme expressions. REFERENCE MANUAL The reference manual for the language implemented by Pseudoscheme is the "Revised^3 Report on the Algorithmic Language Scheme", available as SIGPLAN Notices 21(12) Dec. 1986 or as MIT AI Memo 848a. Following are some extensions provided by Pseudoscheme: - COMPILE-FILE, TRACE, UNTRACE, DESCRIBE, and ED are as in Common Lisp. - (PP x) will pretty-print an S-expression. But don't try to make it print a procedure -- you will probably get bizarre results. - "##" is an expression evaluating to the last expression computed by the read-eval-print loop. This corresponds to "*" in Common Lisp and "(%out)" in MIT Scheme. - CONS-STREAM, THE-EMPTY-STREAM, HEAD, TAIL, EVAL, USER-INITIAL-ENVIRONMENT, SEQUENCE, and ERROR are as in Abelson and Sussman's book. (MAPCAR, MAPC, PRIN1, PRINT, and PRINC don't exist, but they can easily be defined. MAKE-ENVIRONMENT is also missing from Pseudoscheme, and it would be very difficult to add.) - RANDOM is as in Common Lisp and MIT Scheme. Why PSEUDOSCHEME is "pseudo": - Tail-recursion will not work in general, if the host Common Lisp doesn't support it. However, simple loops written with LETREC, LET, DO, or internal DEFINE will macroexpand into the Common Lisp TAGBODY construct, and will therefore execute without exhausting the stack. - CALL-WITH-CURRENT-CONTINUATION gives a "continuation" procedure which can only be passed down, not up. (It's implemented using Common Lisp's BLOCK and RETURN-FROM constructs.) - DO has some obscure restrictions, which I won't bother to document. Creating closures inside of DO's can sometimes do the wrong thing. - #F (which is the same as ()) prints as LISP:NIL (or something similar, such as ZETALISP:NIL or GLOBAL:NIL). Similarly, #T prints as LISP:T. - There is no distinction between inexact and exact numbers; many of Scheme's numerical facilities are neglected. - Combinations whose procedure position is an expression other than a symbol, e.g. ((LAMBDA (X) X) 1) or ((F X) Y), will only work if the expression occurs embedded within some non-combination, e.g. inside the body of a DEFINE or LAMBDA. Most of the time this doesn't make a difference, since most top-level forms are either DEFINE's or don't involve things of this sort. [This restriction is due to Common Lisp's treatment of function position. That Pseudoscheme lets you write ((F X) Y) at all is only by grace of its preprocessor, which only kicks in inside of special forms, and turns such things into (FUNCALL (F X) Y).] About PSEUDOSCHEME: PSEUDOSCHEME works in a very simple-minded way possible: it's a natural embedding, consisting of a set of Common Lisp macro and function definitions. The advantage of a natural embedding is maximal integration with the host environment. Thus the debugger and editor should work pretty smoothly with "Scheme" code. The disadvantages of such an embedding are enumerated above (incomplete tail-recursion and CALL-WITH-CURRENT-CONTINUATION being the most prominent). If you start running up against the limits of the implementation and have questions about what's going on, talk to me or look at the source code. Have fun. - Jonathan Rees Notes on Z:>jar>pseudo.lisp.102 released 1/14/87. - CALL is de-released, since it's almost entirely unnecessary. - All LAMBDA-bound variables now get renamed to have "." prepended, i.e. (LAMBDA (X) X) macroexpands to #'(LISP:LAMBDA (.X) .X). - DEFINE-MACRO should now work, more or less. Notes on Z:>6821>pseudo.lisp.83 released 11/19/86: A number of bugs have been fixed, including the following: - The CALL special form is now unnecessary, except possibly in forms not passed to EVAL and not contained inside of a DEFINE or a special form. - Named LET is fully general. - It should work to have both a global and a lambda-bound variable with the same name (e.g. EXP). - TRANSCRIPT-ON and TRANSCRIPT-OFF should work as per the Revised^3 Report. (LIST ((PAGE NIL (PAPERSIZE LETTER STARTINGPAGE# 219) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO NIL) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE NIL . LETTER) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO NIL) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE NIL . LETTER) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO NIL) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL)))))(È(È(ŠŠ8(ŠŠ8DÈÈ PAGEHEADING RUNNINGHEADMODERN MODERN MODERN MODERNLOGO TIMESROMAN ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8))   HRULE.GETFNMODERN  HRULE.GETFNMODERN  HRULE.GETFNMODERN   HRULE.GETFNMODERN  HRULE.GETFNMODERN V ›èêD3e*ÇÆ8Iƒ«F0µŒ“þŠ2A†02ÏbL‘`zº