[Top][All Lists]

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

[MIT-Scheme-devel] fasl hook or something

From: Matt Birkholz
Subject: [MIT-Scheme-devel] fasl hook or something
Date: Mon, 10 May 2010 14:11:13 -0700

> From: Joe Marshall <address@hidden>
> Date: Fri, 7 May 2010 11:43:00 -0700
> I want to intern some objects, but I want to be able to fasdump and
> fasload them, too.  Is there any reasonable way (or unreasonable,
> for that matter), to hook into the fasloader to intern things when
> they are restored?

A simple test can determine if your object was recently fasloaded, at
which point you can re-intern (on-demand).  E.g.

    (define-structure thing tag unique)

    (define (thing.unique t)
      (if (eq? unique-tag (thing-tag t))
          (thing-unique t)
          (let ((new (re-intern-unique (thing-unique t))))
            (set-thing-unique! t new)
            (set-thing-tag! t unique-tag)

    ;; This cannot match any fasloaded string, until some smart-*ss
    ;; adds fancy constant string sharing yabber to my KISS runtime... :-}
    (define unique-tag "constant string, shared or not")

The real trick is cutting your objects off from their methods.  These
insidious devils are (one?) reason why this happens:

    1 ]=> (fasdump (make-thing unique-tag 'stand-in) "thing.bin")

    ;Dumping "thing.bin"... 
    ;Object cannot be dumped because it contains an environment: #[thing 19]
    ;To continue, call RESTART with an option number:

and why I have been heard to incant:

(define-structure (alien-function
                   ;; To be fasdump/loadable.
                   (type vector) (named 'alien-function)

reply via email to

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