Changes for the 01nov91jfb release of Scheme->C


Documentation

1.  The PostScript for r3rs is now included in the release.  A minor change
    had to be made to the file to allow it to be printed on some printers.
    See the comments in doc/r3rs.psf for details.

2.  Notes for using Scheme->C with "An Introduction to Scheme" by Jerry D.
    Smith are now included in the documentation.

3.  The index has been updated to reflect additions to the implementation.


Additional Features

1.  DEFINE-C-EXTERNAL now allows external arrays to be defined using the
    keyword array.

2.  Objects on the *FROZEN-OBJECTS* list are never moved by the garbage
    collector.  User programs can use this to "lock" objects that are passed
    to other languages.

3.  When (CATCH-ERROR procedure) evaluates the procedure, it returns either
    a list containing the value or a string containing the error message.

4.  A shell command can be issued by (SYSTEM string).  See the man page for
    system for details on its execution.

5.  OPEN-INPUT-PROCESS, OPEN-OUTPUT-PROCESS, and OPEN-PROCESS allow I/O to a
    process.  See the man page for popen for details.

6.  Added WRITE-CIRCLE, SET-WRITE-CIRCLE!, WRITE-LEVEL, SET-WRITE-LEVEL!,
    WRITE-LENGTH, SET-WRITE-LENGTH!, WRITE-PRETTY, and SET-WRITE-PRETTY! to
    control I/O options on a port by port basis.  The implementation is
    similar to that provided by Common LISP.  For example:

	csh 2 >sci
	Scheme->C -- 01nov91jfb -- Copyright 1989 Digital Equipment Corporation
	> (loade "zz.sc")
	(for-each
	    (lambda (v n)
 	           (set-write-level! v)
 	           (set-write-length! n)
 	           (format #t "~s ~s   ~s~%" v n
 	                   '(if (member x y) (+ (car x) 3)
 	                        '(foo . #(a b c d "Baz")))))
	    '(0 1 1 1 1 2 2 2 3 3 3 #f)
	    '(1 1 2 3 4 1 2 3 2 3 4 #f))
	0 1     #
	1 1     (IF ...)
	1 2     (IF # ...)
	1 3     (IF # # ...)
	1 4     (IF # # #)
	2 1     (IF ...)
	2 2     (IF (MEMBER X ...) ...)
	2 3     (IF (MEMBER X Y) (+ # 3) ...)
	3 2     (IF (MEMBER X ...) ...)
	3 3     (IF (MEMBER X Y) (+ (CAR X) 3) ...)
	3 4     (IF (MEMBER X Y) (+ (CAR X) 3) '(FOO . #(A B C D ...)))
	#F #F   (IF (MEMBER X Y) (+ (CAR X) 3) '(FOO . #(A B C D "Baz")))

	#F
	"zz.sc"
	> ^D
	csh 3 >

7.  Added sc_delete_global_TSCP() to unregister a TSCP global declared in
    another language.

8.  Interpreter is now significantly faster.  Use OPTIMIZE-EVAL to select
    additional interpreter optimization.

9.  Added support for Big Endian MIPS machines such as those built by SGI.

10. Added procedures STRING and LIST?.

11. Heap can now be dynamically expanded.  For example:

	csh 9 >!sc
	sci -scgc 1 -scmh 20
	***** SCGCINFO = 1  SCHEAP = 4  SCMAXHEAP = 20  SCLIMIT = 33
	Scheme->C -- 01nov91jfb -- Copyright 1989 Digital Equipment Corporation
	> (vector-length (make-vector 1000000))

	***** COLLECT 1% allocated (0% waste, 4 MB) ->
              0% locked  1% retained  35 user ms  3 system ms  0 page faults

	***** COLLECT heap expanded to 8 MB

	***** COLLECT 0% allocated (0% waste, 8 MB) ->
              0% locked  0% retained  11 user ms  0 system ms  0 page faults
	1000000
	> ^D
	csh 10 >

12. GETPROP-ALL returns the property list for a symbol.

13. The initial heap image file name is saved in *INITIAL-HEAP-FILE*.


Bugs Corrected / Misc. Changes

1.  Street address for DECWRL changed in copyright/license notice.

2.  Some code generation problems related to constants having the same
    value as top-level symbol names have been fixed.  For example, the
    following now correctly compiles:

	(module x)
	(define-external x top-level)
	(define (T1) `(x 1) (x))

3.  X1 through X299 are now available for use as temporary variable names
    in the compiled code.

4.  Code for non-printing characters in strings is now correct.

5.  Multiple options in eval-when when forms like 
    (eval-when (compile load) ...) are now correctly handled.

6.  Pointers to external procedures returning non-integer type values are now
    correct.  For example, the following program is now correctly leaves the
    address of the C library routine hypot in the Scheme top level variable
    hypot.

	(module x)
	(define-c-external (c-hypot double double) double "hypot")
	(define hypot c-hypot)

7.  In examples like the following, an attempt was made to optimize out
    the calls to g.  This is incorrect and has been fixed as g takes
    arguments which must be evaluated.

	(module test)
	(define a 3)

	(define (f)
  	   (let ((a 4)
        	 (g (lambda (x) a)))
    	        (g (g (display 1)))))

8.  An error is reported when top-level is used as a module name.

9.  When the -i command creates an interpreter, the module names specified
    by -m commands or in .sc files are now initialized in the order that
    they appear in the command line.

10. As scrt/predef.sc has increased, the base sequence number for generated
    program variables has been changed from 1000 to 2000.

11. A definition for a variable declared to be top-level or in the module
    containing the definition will no longer cause a warning.  For example, the
    following program now compiles with no warnings:

	(module zort)
	(define-external a zort)
	(define-external b top-level)
	(define a 23)
	(define b 24)

12. Closure analysis now picks up variables closed by inclusion in an inline
    tail call.  I.e, the following is now correctly compiled:

	(module query
	  (top-level interpret-query))

	(define (interpret-query query item-identifier)
	  (define (examine-each fn)
	    (item-identifier 3))
	  
	  (define (internal-interpret q)
	    (case (car query)
	      ((and)				; (AND <query> ...)
	       (map internal-interpret (cdr query)))

	      ((contains?)			
	       (case (length query)
		 ((2) (examine-each		; (CONTAINS? word)
		       (lambda (record) 3)))
		 ((3)				; (CONTAINS? word field)
		  (examine-each
		   (lambda (record) 3)))))))

	  (internal-interpret query))

13. Named let expansion corrected to all arguments are evaluated before
    anything is bound.

14. Delete conditional code for graphical garbage collector (GGC ifdefs in
    scinit.c and heap.c).

15. Improved performance for reading numbers.

16. Garbage collector no longer assumes that all constants created in the
    same generation.

17. Apply now correctly copies the optional argument list so the following is
    now true:

	(define x '(a b c))
	(eq? x (apply list x)) ==> #F	(was #T which is incorrect)

18. The definition for jmp_buf is not supplied by objects.h for some systems.

19. The macro expansion for named let's has been changed to assure that the
    initial expressions are evaluated before any bindings are done.

20. The compiler reports an error when it runs out of temorary variables.

21. One fallout of the new, faster interpreter is that it leaves more "debris"
    in the stack on some RISC systems.  As a result, some programs which make
    extensive use of call-with-current-continuation require a larger heap
    than on the 28sep90 release.  If this is a problem, then rebuild the
    system using the 28sep90 version of sceval.sc:

--------------------------- begin sceval.sc ----------------------------------
;;; This module implements a simple Scheme evaluator.
;;;
;;; Initialization of this module will assure that all modules in the
;;; "standard" library are initialized.

;*              Copyright 1989 Digital Equipment Corporation
;*                         All Rights Reserved
;*
;* Permission to use, copy, and modify this software and its documentation is
;* hereby granted only under the following terms and conditions.  Both the
;* above copyright notice and this permission notice must appear in all copies
;* of the software, derivative works or modified versions, and any portions
;* thereof, and both notices must appear in supporting documentation.
;*
;* Users of this software agree to the terms and conditions set forth herein,
;* and hereby grant back to Digital a non-exclusive, unrestricted, royalty-free
;* right and license under any changes, enhancements or extensions made to the
;* core functions of the software, including but not limited to those affording
;* compatibility with other hardware or software environments, but excluding
;* applications which incorporate this software.  Users further agree to use
;* their best efforts to return to Digital any such changes, enhancements or
;* extensions that they make and inform Digital of noteworthy uses of this
;* software.  Correspondence should be provided to Digital at:
;* 
;*                       Director of Licensing
;*                       Western Research Laboratory
;*                       Digital Equipment Corporation
;*                       100 Hamilton Avenue
;*                       Palo Alto, California  94301  
;* 
;* This software may be distributed (but not offered for sale or transferred
;* for compensation) to third parties, provided such third parties agree to
;* abide by the terms and conditions of this notice.  
;* 
;* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
;* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
;* MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
;* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
;* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
;* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
;* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
;* SOFTWARE.

(module sceval
    (top-level EVAL)
    (with scrt1 scrt2 scrt3 scrt4 scrt5 scrt6 scrt7))

(include "repdef.sc")

(define-c-external (PROCEDURE->ADDRESS tscp) unsigned "sc_procedureaddress")

;;; The Scheme interpreter starts here.

(define (EVAL form . env)
    (exec (expand form) (if env (car env) '())))

(define (NEW-ENV idl vals env)
    (cond ((null? idl)
	   (if vals (error 'NEW-ENV "Too many arguments to function"))
	   env)
	  ((symbol? idl)
	   (cons (cons idl vals) env))
	  ((null? vals)
	   (error 'NEW-ENV "Too few arguments to function"))
	  (else
	   (cons (cons (car idl) (car vals))
		 (new-env (cdr idl) (cdr vals) env)))))

(define (LOOKUP id env)
    (let ((pair (assq id env)))
	 (if pair
	     (cdr pair)
	     (let ((val (top-level-value id)))
		  (if (eq? val $_undefined)
		      (error id "Top-level symbol is undefined")
		      val)))))

(define (ASSIGN id val env)
        (let ((pair (assq id env)))
         (if pair (set-cdr! pair val) (set-top-level-value! id val))))

(define (EXEC exp env)
    ((lap (x y) (LOOPSTACKTRACE x y)) exp env)
    (cond ((symbol? exp)
	   (lookup exp env))
	  ((pair? exp)
	   (case (car exp)
		 ((quote)
		  (cadr exp))
		 ((lambda)
		  (let ((env  env)
			(vars (cadr exp))
			(body (cons 'begin (cddr exp))))
		       (lambda vals
			       (if interpreted-tail-call
				   (list body (new-env vars vals env))
				   (exec body (new-env vars vals env))))))
		 ((if)
		  (if (exec (cadr exp) env)
		      (exec (caddr exp) env)
		      (exec (cadddr exp) env)))
		 ((set!)
		  (assign (cadr exp) (exec (caddr exp) env) env))
		 ((begin)
		  (do ((exps (cdr exp) (cdr exps)))
		      ((null? (cdr exps)) (exec (car exps) env))
		      (exec (car exps) env)))
		 (else
		  (let ((function (exec (car exp) env))
			(args (let loop ((x (cdr exp)) (env env))
				   (if (null? x)
				       x
				       (cons (exec (car x) env)
					     (loop (cdr x) env)))))
			(exp-env '()))
		       (cond ((not (procedure? function))
			      (error 'exec
				     "Argument value is not a function: ~s"
				     (car exp)))
			     ((eqv? (procedure->address function)
				    (procedure->address interpreted-proc))
			      (set! interpreted-tail-call #t)
			      (set! exp-env (apply function args))
			      (set! interpreted-tail-call #f)
			      (exec (car exp-env) (cadr exp-env)))
			     (else (apply function args)))))))
	  ((number? exp) exp)
	  ((string? exp) exp)
	  ((char? exp) exp)
	  ((boolean? exp) exp)
	  (else (error 'exec "Argument is not self-evaluating: ~s" exp))))

(define INTERPRETED-TAIL-CALL '())

(define INTERPRETED-PROC (exec '(lambda (x) x) '()))
---------------------------- end sceval.sc ------------------------------
