#| -*-Scheme-*-
-$Id: make.scm,v 14.58 1996/04/24 04:23:54 cph Exp $
+$Id: make.scm,v 14.59 1997/06/24 05:34:15 cph Exp $
-Copyright (c) 1988-96 Massachusetts Institute of Technology
+Copyright (c) 1988-97 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
(RUNTIME MICROCODE-ERRORS)
((RUNTIME GENERIC-PROCEDURE) INITIALIZE-CONDITIONS! #t)
((RUNTIME GENERIC-PROCEDURE MULTIPLEXER) INITIALIZE-CONDITIONS! #t)
+ ((RUNTIME RECORD-SLOT-ACCESS) INITIALIZE-CONDITIONS! #t)
;; System dependent stuff
(() INITIALIZE-SYSTEM-PRIMITIVES! #f)
;; Threads
;;; -*-Scheme-*-
;;;
-;;; $Id: recslot.scm,v 1.1 1996/04/23 20:37:58 cph Exp $
+;;; $Id: recslot.scm,v 1.2 1997/06/24 05:33:57 cph Exp $
;;;
-;;; Copyright (c) 1995-96 Massachusetts Institute of Technology
+;;; Copyright (c) 1995-97 Massachusetts Institute of Technology
;;;
;;; This material was developed by the Scheme project at the
;;; Massachusetts Institute of Technology, Department of Electrical
(define (%record-accessor index)
(generate-index-cases index 16
(lambda (index)
- (declare (integrate index))
- (lambda (record) (%record-ref record index)))))
+ (declare (integrate index)
+ (ignore-reference-traps (set record-slot-uninitialized)))
+ (lambda (record)
+ (if (eq? record-slot-uninitialized (%record-ref record index))
+ (error:uninitialized-slot record index)
+ (%record-ref record index))))))
(define (%record-modifier index)
(generate-index-cases index 16
(define (%record-initpred index)
(generate-index-cases index 16
(lambda (index)
- (declare (integrate index))
+ (declare (integrate index)
+ (ignore-reference-traps (set record-slot-uninitialized)))
(lambda (record)
(not (eq? record-slot-uninitialized (%record-ref record index)))))))
+(define (%record-slot-name record index)
+ (if (not (and (exact-integer? index) (positive? index)))
+ (error:wrong-type-argument index "record index" '%RECORD-SLOT-NAME))
+ (let ((names
+ (call-with-current-continuation
+ (lambda (k)
+ (bind-condition-handler (list condition-type:no-applicable-methods)
+ (lambda (condition) condition (k 'UNKNOWN))
+ (lambda ()
+ (%record-slot-names record))))))
+ (index (- index 1)))
+ (and (list? names)
+ (< index (length names))
+ (list-ref names index))))
+\f
(define %record-slot-index)
(define %record-slot-names)
generic
(and (record-type? (dispatch-tag-contents (car tags)))
(lambda (record)
- (record-type-field-names (record-type-descriptor record)))))))
\ No newline at end of file
+ (record-type-field-names (record-type-descriptor record)))))))
+
+(define condition-type:uninitialized-slot)
+(define error:uninitialized-slot)
+
+(define (initialize-conditions!)
+ (set! condition-type:uninitialized-slot
+ (make-condition-type 'UNINITIALIZED-SLOT condition-type:cell-error
+ '(RECORD)
+ (lambda (condition port)
+ (write-string "Attempt to reference slot " port)
+ (write (access-condition condition 'LOCATION) port)
+ (write-string " in record " port)
+ (write (access-condition condition 'RECORD) port)
+ (write-string " failed because the slot is not initialized."
+ port))))
+ (set! error:uninitialized-slot
+ (let ((signal
+ (condition-signaller condition-type:uninitialized-slot
+ '(RECORD LOCATION)
+ standard-error-handler)))
+ (lambda (record index)
+ (let ((location
+ (or (%record-slot-name record index)
+ index)))
+ (call-with-current-continuation
+ (lambda (k)
+ (with-restart 'STORE-VALUE
+ (lambda (port)
+ (write-string "Initialize slot " port)
+ (write location port)
+ (write-string " to a given value." port))
+ (lambda (value)
+ (%record-set! record index value)
+ (k value))
+ (let ((prompt
+ (string-append "Set "
+ (write-to-string location)
+ " to")))
+ (lambda ()
+ (values (prompt-for-evaluated-expression prompt))))
+ (lambda ()
+ (with-restart 'USE-VALUE
+ (lambda (port)
+ (write-string
+ "Specify a value to use instead of the contents of slot "
+ port)
+ (write location port)
+ (write-string "." port))
+ k
+ (let ((prompt
+ (string-append "Value to use instead of "
+ (write-to-string location))))
+ (lambda ()
+ (values
+ (prompt-for-evaluated-expression prompt))))
+ (lambda ()
+ (signal record location)))))))))))
+ unspecific)
\ No newline at end of file
#| -*-Scheme-*-
-$Id: make.scm,v 14.61 1996/07/26 14:38:26 adams Exp $
+$Id: make.scm,v 14.62 1997/06/24 05:34:09 cph Exp $
-Copyright (c) 1988-96 Massachusetts Institute of Technology
+Copyright (c) 1988-97 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
(RUNTIME MICROCODE-ERRORS)
((RUNTIME GENERIC-PROCEDURE) INITIALIZE-CONDITIONS! #t)
((RUNTIME GENERIC-PROCEDURE MULTIPLEXER) INITIALIZE-CONDITIONS! #t)
+ ((RUNTIME RECORD-SLOT-ACCESS) INITIALIZE-CONDITIONS! #t)
;; System dependent stuff
(() INITIALIZE-SYSTEM-PRIMITIVES! #f)
;; Threads