Next: , Previous: , Up: compiler recordize   [Index]


17.8.3 Recordisation examples

Handling of imported bindings

Let’s imagine the following library:

(library (libtest compiler-internals)
  (export a-func a-thunk a-const)
  (import (rnrs (6)))
  (define (a-func a b)
    (+ a b))
  (define (a-thunk)
    "ciao")
  (define a-const 123))

it is recordised as follows:

(rec*bind ((a-func_0  (lambda (a_0 b_0)
                        (funcall (primref +) a_0 b_0)))
           (a-thunk_0 (lambda ()
                        (constant "ciao")))
           (a-const_0 (constant 123)))
  (constant #<void>))

if this library is imported as in:

(library (recordize-demo-1)
  (export)
  (import (rnrs) (libtest compiler-internals))
  (list a-const (a-thunk) (a-func 1 2)))

the resulting recordised code is:

(rec*bind ()
  (funcall (primref list)
           (funcall (primref top-level-value)
                    (constant a-const))
           (funcall (funcall (primref top-level-value)
                             (constant a-thunk)))
           (funcall (funcall (primref top-level-value)
                             (constant a-func))
                             (constant 1)
                             (constant 2))))

where the symbols a-const, a-thunk, a-func are the location gensyms of the imported bindings.