Changeset 15275 in project for chicken


Ignore:
Timestamp:
07/29/09 11:10:09 (10 years ago)
Author:
felix winkelmann
Message:

handle errors when deleting files and optional loading for compile-file

Location:
chicken/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/manual/Unit utils

    r15262 r15275  
    8181==== compile-file
    8282
    83  [procedure] (compile-file FILENAME #!key options output-file)
     83 [procedure] (compile-file FILENAME #!key options output-file load)
    8484
    8585Compiles the Scheme source file {{FILENAME}} into a dynamically
    8686loadable library by invoking the {{csc}} compiler driver. If the
    87 library can be successfully created, it is loaded into the current
     87library can be successfully created and {{load}} is not given or
     88true, the file is loaded into the current
    8889Scheme process. {{options}} may be a list of strings which are passed
    8990as additional command line options to {{csc}}. If {{output-file}} is
  • chicken/trunk/utils.scm

    r15274 r15275  
    128128(define compile-file
    129129  (let ((csc (foreign-value "C_CSC_PROGRAM" c-string))
    130         (path (foreign-value "C_INSTALL_BIN_HOME" c-string)) )
    131     (lambda (filename #!key (options '()) output-file)
     130        (path (foreign-value "C_INSTALL_BIN_HOME" c-string))
     131        (load-file load))
     132    (lambda (filename #!key (options '()) output-file (load #t))
    132133      (let ((cscpath (or (file-exists? (make-pathname path csc)) "csc"))
    133134            (tmpfile (and (not output-file) (create-temporary-file "so")))
     
    143144         (if crapshell "\"" ""))
    144145        (unless output-file
    145           (on-exit (cut delete-file* tmpfile)))
    146         (let ((f (or output-file tmpfile)))
    147           (handle-exceptions ex
    148               (begin
    149                 (delete-file* f)
    150                 (abort ex))
    151             (load f)
    152             f))))))
     146          (on-exit
     147           (lambda ()
     148             (handle-exceptions ex #f (delete-file* tmpfile)))))
     149        (when load
     150          (let ((f (or output-file tmpfile)))
     151            (handle-exceptions ex
     152                (begin
     153                  (delete-file* f)
     154                  (abort ex))
     155              (load-file f)
     156              f)))))))
Note: See TracChangeset for help on using the changeset viewer.