chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] extreme kludge: load that compiles


From: Eduardo Cavazos
Subject: [Chicken-users] extreme kludge: load that compiles
Date: Wed, 18 Feb 2009 12:40:40 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.16) Gecko/20080716 SeaMonkey/1.1.11

Hello,

Even after R6RS, 'load' is all one can really count on. :-)

Below is a "hacked" version of load that I'm using for Chicken. If an '.so' file doesn't exist for the file your loading, the file is compiled and one is generated. If it does exist but it's out of date, your file is recompiled, then the '.so' file is loaded. Otherwise, the '.so' is loaded straight away.

Ed

(use files)
(use posix)

(define chicken-scheme-load load)

(define (file-newer? a b)
  (> (file-change-time a)
     (file-change-time b)))

(define (load scheme-file)

  (let ((so-file (pathname-replace-extension scheme-file "so")))

    (cond

     ((and (file-exists? so-file)
           (file-newer? so-file scheme-file))
      (chicken-scheme-load so-file))

     (else
      (display "Compiling file: ") (display scheme-file) (newline)

      (system (string-append "csc -dynamic -run-time-macros " scheme-file))

        (load scheme-file)))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]