[<<][staapl][>>][..]
Fri Apr 24 16:24:24 CEST 2009

syntaxes and units

What I don't understand is why syntax transformer definition has to be
part of a unit's signature.

Maybe it helps to understand how units are implemented...

So, an identifier in a unit is a rename transformer.

What better than to look at the expansion?

(define-signature foo^ (foo (define-syntaxes (baz) '(1 2 3))))
(define-signature bar^ (bar))

(expand
 #'(unit
     (import foo^)
     (export bar^)
     (define bar (+ 123))
     (define-syntax (print-baz stx)
       (printf "baz: ~a\n" (syntax-local-value #'baz))
       #'456)
     (print-baz)))

PRINTS:
baz: (1 2 3)

VALUE:
(#%app
 make-unit
 'eval:42:0
 (#%app
  vector-immutable
  (#%app cons 'foo^ (#%app vector-immutable (#%top . signature-tag))))
 (#%app
  vector-immutable
  (#%app cons 'bar^ (#%app vector-immutable (#%top . signature-tag))))
 (#%app list)
 (let-values ()
   (let-values ()
     (lambda ()
       (let-values (((temp51) (#%app box undefined)))
         (#%app
          values
          (lambda (import-table)
            (let-values (((temp50)
                          (#%app
                           vector->values
                           (#%app
                            hash-table-get
                            import-table
                            (#%top . signature-tag))
                           '0
                           '1)))
              (let-values ()
                (let-values ()
                  (letrec-values (((bar) (#%app + '123)))
                    (#%app set-box! temp51 bar)
                    '456)))))
          (#%app
           make-immutable-hash
           (#%app
            list
            (#%app
             cons
             (#%top . signature-tag)
             (#%app vector-immutable (lambda () (#%app unbox temp51))))))))))))


Judging from this, units are completely compiled once defined.  This
consumes the signature info.  All the information that's necessary at
compile time needs to be provided _in the signature_.

The compile-time info patterns-tx depends on thus needs to be embedded
in the signatures also.  Looks like it's best to define operations
themselves as signatures.

What is necessary is the separation of interface and implementation
for the assembler opcodes.  Opcodes should be _declared_ somewhere,
then when _defined_ the declaration should be verified (or possibly
created).

Maybe the signature can be stored _inside_ the static info?

(define-syntax (define-op-signature stx)
  (syntax-case stx ()
    ((_ name^ (name arg ...) ...)
     _ _ _)))



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