[racket] current-load/use-compiled and old .zo files
Hi!
Each time I install a new version of Racket I have a problem with the
old .zo files compiled with the old version.
I have the following program in my personal root racket folder that I
use to compile all the files in all the subfolders:
;---
#lang racket/base
(require compiler/compiler)
(require setup/getinfo)
(compile-directory-zos (current-directory)
(get-info/full (current-directory)))
;---
After upgrading, I get the error:
[file] read (compiled): wrong version for compiled code
compiled version: 5.3
expected version: 5.3.1
So, I have to manually delete all the old .zo files that are
distributed in many subfolders.
Now I'm using the following program that automatically deletes the old
.zo files. (Warning: I'm not sure that in some corner case it can't
delete the wrong file.)
;---
#lang racket/base
(require compiler/compiler)
(require setup/getinfo)
(let ([old-c-l/u-c (current-load/use-compiled)])
(parameterize ([current-load/use-compiled {lambda (path name)
(with-handlers*
([exn:fail:read? {lambda (exn)
(write (srcloc-source (car (exn:fail:read-srclocs exn))))
(delete-file (srcloc-source (car (exn:fail:read-srclocs
exn))))
(old-c-l/u-c path name)}])
(old-c-l/u-c path name))}])
(compile-directory-zos (current-directory)
(get-info/full (current-directory)))))
;---
But it still has problems with the .ss files that have a compiled version.
Is there a more elegant/correct way to do this?
I saw the implementation of default-load/use-compiled, but it's very
long. Is it possible to change the implementation of it, so it use the
.zo files only when they have the correct version?
Gustavo