Sun Apr 26 01:47:00 CEST 2009

compile time is compile time

Q: The problems I'm trying to solve at this moment are about run-time
   values not matching across unit boundaries.  What about avoiding
   these run-time values and turning the macros into proper macros
   (executing at scheme compile time).  Would that solve anything?

Really, I should find a simple test case first..  Rewriting the
RPN compiler was (is) fun and necessary for clarity, but units aren't
modules when it comes to macros..

The following example shows otherwise: values are properly shared, the
module is instantiated only once.  (eq? it1 it2) => #t

;; it.ss
#lang scheme/base
(provide it)
(printf "instantiating it\n")
(define it "it")

;; sig.ss
#lang scheme/base
(require scheme/unit)
(provide sig1^ sig2^)
(define-signature sig1^ (it1))
(define-signature sig2^ (it2))

;; top.ss
#lang scheme/base
(require "unit1.ss"
(define-syntax-rule (define/invoke (sig ...) (unit ...))
    (define-compound-unit/infer combined@
      (export sig ...)
      (link unit ...))
    (define-values/invoke-unit combined@
      (export sig ...))))
(define/invoke (sig1^ sig2^) (unit1@ unit2@))

;; unit1.ss
#lang scheme/unit
(require "sig.ss" "it.ss")
(export sig1^)
(define it1 it)

;; unit2.ss
#lang scheme/unit
(require "sig.ss" "it.ss")
(export sig2^)
(define it2 it)

So.. what is the problem then?

Is it because values are somehow wrapped?  Is this related to the
remark that eq? doesn't work across unit boundaries?

Maybe I should accept that the eq? is bad practice.  The assembler
instance can't be used for pattern matching.  Maybe it should just
match the name then..