[r6rs-discuss] [Formal] Remove double phase semantics (fwd)

From: AndrevanTonder <andre>
Date: Sun Nov 26 12:22:09 2006

On Sun, 26 Nov 2006, William D Clinger wrote:

> Are you sure? It looks to me as though the separated binding
> semantics ensures that
>
> - A library *will* behave differently when imported for RUN than it
> does when imported for EXPAND.
>
> - A library that has been tested in one phase *is likely to* stop
> working when imported into a different phase instead.
>
> - A library that has been tested when imported into one phase *is
> likely to* stop working when imported into more than one phase
> simultaneously.
>
> I hope I'm wrong, but I don't see how.

Here is a simple example. I am not claiming that this is an example of good
style, or that libraries should be written this way, but hopefully it
illustrates the point:

    (library foo
      (export counter)
      (import r6rs)
      (define counter
        (let ((x 0))
          (lambda ()
            (set! x (+ x 1))
            x))))

    (library bar
      (export)
      (import r6rs (for foo run expand))
      (let-syntax ((m (lambda (e) (counter))))
        (display (list (m) (counter)))))

    (library baz
      (export)
      (import bar))

        ;==> (1 1) in the separated binding semantics always
             (1 1) in the shared semantics with separate compilation
             (1 2) in the shared semantics with compilation/run in same
                   image

    (library bax
      (export)
      (import (for bar expand)))

        ;==> (1 1) in the separated binding semantics always
             (1 2) in the shared semantics with separate compilation
             (1 2) in the shared semantics with compilation/run in same
                   image

So with the separated binding semantics, one gets a predictable result.
With shared bindings, on the other hand

  - the behaviour of BAZ depends on whether compilation/running happen
    in the same image or in separate images.
  - even with separate compilation, the behaviour of BAZ depends on
    whether it has been imported for RUN or for EXPAND.

Cheers
Andre
Received on Sun Nov 26 2006 - 12:17:47 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:00 UTC