[<<][staapl][>>][..]
Thu Mar 24 20:59:55 EDT 2011

Unit unions

Let's just build and abstraction for it.  I don't think that compound
signatures are possible, except for the limited single-inheritance.

So I got something working:

(define-syntax (define-dictionary stx)
  (syntax-case stx ()
    ((_ name (sig^ ...))
     #`(define-syntax name #'(sig^ ...)))))

(begin-for-syntax
 (define (re-syntax context stx)
   (datum->syntax context (syntax->datum stx))))

(define-syntax (define/invoke-dictionary stx)
  (syntax-case stx ()
    ((_ dict^^ (unit@ ...))
     (let ((sigs (re-syntax stx (syntax-local-value #'dict^^))))
       #`(begin
           (define-compound-unit/infer combined@
             (import)
             (export #,@sigs)
             (link unit@ ...))
           (define-values/invoke-unit combined@
             (import)
             (export #,@sigs)))))))

And then:

(define-dictionary pic18^^
  (stack^
   stack-extra^
   memory-extra^
   .. ))


This works, but only because the symbols are non-hygienic.  I can't
seem to keep the signatures themselves hidden, and export the
definitions.



[Reply][About]
[<<][staapl][>>][..]