I'm trying to use syntax-local-lift to lift the definition of a structure to the top level.
syntax-local-lift-module-end-declaration doesn't work because it is not guaranteed to be in an expression context, so I can't have a define. syntax-local-lift-expression doesn't work because it only works for establishing a single binding, whereas a structure definition requires 3+2n bindings. I thought that I might be able to simulate this: #lang scheme (require (for-syntax scheme/list)) (define-for-syntax (syntax-local-lift-expression/values how-many stx) (define the-values-id (syntax-local-lift-expression (quasisyntax/loc stx (call-with-values #,stx (lambda the-values the-values))))) (build-list how-many (lambda (which-value) (syntax-local-lift-expression (quasisyntax/loc stx (list-ref #,the-values-id #,which-value)))))) (define-syntax (testit stx) (syntax-case stx () [(_) (let ([the-values (syntax-local-lift-expression/values 3 (syntax/loc stx (values 1 2 3)))]) (syntax-local-lift-module-end-declaration (quasisyntax/loc stx (begin #,@(map (lambda (value-id) (quasisyntax/loc stx (printf "~S~n" #,value-id))) the-values))))) (syntax/loc stx (printf "Lifted~n"))])) (testit) But I cannot, because syntax-local-lift-expression puts things in the reverse order of the calls. This is expanded in the macro stepper to: (define-values (lifted.6:84) (#%app:85 list-ref:86 lifted.0:87 '2)) (define-values (lifted.4:88) (#%app:89 list-ref:86 lifted.0:87 '1)) (define-values (lifted.2:90) (#%app:91 list-ref:86 lifted.0:87 '0)) (define-values (lifted.0:87) (#%app:92 call-with-values:86 (#%app:93 values:86 (quote 1) (quote 2) (quote 3)) (lambda:94 the-values:86 the-values:86))) (#%app:96 call-with-values:96 (lambda:96 () (#%app:95 printf:86 (quote "Lifted~n"))) print-values:96) (#%app:97 printf:86 (quote "~S~n") lifted.2:90) (#%app:98 printf:86 (quote "~S~n") lifted.4:88) (#%app:99 printf:86 (quote "~S~n") lifted.6:84) So... can we get either of these changed? Either a native syntax-local-lift-expressions or put the syntax-local-lift-expression calls in the order they are given, rather than the reverse? Jay -- Jay McCarthy <j...@cs.byu.edu> Assistant Professor / Brigham Young University http://teammccarthy.org/jay "The glory of God is Intelligence" - D&C 93 _________________________________________________ For list-related administrative tasks: http://list.cs.brown.edu/mailman/listinfo/plt-dev