;;OTHER-LOADSM.SCM                                       10:38am Oct. 19, 1998

;   MIT SCHEME INITIALIZATION OF SCHEME SUBSTITUTION MODEL INTERPRETER

;       FOR SCHEME DIALECTS OTHER THAN MIT SCHEME and DRSCHEME,

;This file should be run in a directory containing files "SM.SCM" and "MATCH.SCM".
;BEFORE evaluating this file, you must FILL IN:

(define (call-underlying-scheme expr) (eval expr <ENV REF>)) ;FILL THIS IN 
   ;FOR R5RS Scheme <ENV REF> is (scheme-report-environment 5)

;(define pretty-print display) ;if implementation does not implement PRETTY-PRINT
;(define pretty-print p)       ;Scheme48 on Win95

;Evaluation of (ABORT MSG) will cause an immediate return to the
;user REPL which will return the value of MSG.

(define abort 'dummy)
;;;ATTENTION!!!     EVAL THE FOLLOWING EXPRESSION IN THE USER READ-EVAL-PRINT-LOOP
;                   -- NOT WITH A "LOAD" COMMAND:
;(call-with-current-continuation (lambda (k) (set! abort k)))

(define no-gensym? #f)
   ;(define gensym <GENSYM DEF>)        ;FILL IN <GENSYM DEF>, OR
                                        ;ALTERNATIVELY, EVALUATE 
      ;(set! no-gensym? #t)


(begin
  (load "sm.scm")                       ;load substitution model code
  (newline)
  (display "To start the submodel interpreter, evaluate")
  (newline)
  (display "(NEW-SUBMODEL)")
  (newline)
  (display "See the file SM.SCM for more instructions.")
  (newline) (newline)
  (display "Remember to evaluate in user REPL:")
  (newline)
  (display  '(call/cc (lambda (k) (set! abort k))))
  (if no-gensym?
      (set! crule:call/cc               ;revision to avoid use of GENSYM
            (make-general-control-rule
             '(call/cc ?%val)
             (lambda (receiver-proc context)
               (let ((v (get-cleaned-variable
                         (match-variables-of
                          (list context)))))
                 `(,receiver-proc
                   (lambda (,v) (abort ,(insert-into-hole context v)))))))))
  'sm-loaded)
