[plt-scheme] Fun with phases! function application is not allowed, because no #%app syntax transformer is bound

From: Noel Welsh (noelwelsh at gmail.com)
Date: Tue May 29 08:58:14 EDT 2007

Hi all,

I have a macro that generates a complaint thus:

Welcome to MzScheme v370.2 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
parse.ss:62:10: compile: bad syntax; function application is not
allowed, because no #%app syntax transformer is bound in:
(make-FunDecl (name->c-name (quote v+.)) (make-function-parameters
(list (cons (quote a) F64Vector))) (make-type F64) (list (make-VarDecl
(quote result) F64) (let ((var-posn (symbol-append (quote x) (quote
_posn)))) (make-ForLoop (list (make-VarDecl (qu...

I'm writing a compiler for a limited set of comprehensions.  The
important parts are:

   - module ast defines the AST
   - module parse requires ast.ss and contains a function, parse, that
converts syntax to the syntax of AST construction.

  (define (parse stx)
    (syntax-case stx ()
      [(define-cc (name [param type] ...) return body)
       (with-syntax ([body-expr (parse-body (syntax return) (syntax body))])
         (syntax
          (make-FunDecl (name->c-name (quote name))
                        (make-function-parameters
                         (list (cons (quote param)
                                     type) ...))
                        (make-type return)
                        body-expr)))]))

  - module cc requires-for-syntax parse.ss and contains a macro
define-cc that calls parse

  (define-syntax (define-cc stx)
    (syntax-case stx ()
      [(define-cc (name [arg type] ...) return
         body)
       (with-syntax ([ast (parse stx)])
         (syntax
          (begin
            (compile-ec (quote name) ast)
            (define name
              (if (shared-object-exists? (quote name))
                  (load-function (quote name)
                                 (make-function-type (list type ...) return))
                  (lambda (arg ...)
                    body))))))]))

>From a bit of searching I gather my error message indicates a phase
problem, but I don't really understand how it is occurring.  I've
tried a few things with require-for-template but to no effect.

Thanks,
Noel


Posted on the users mailing list.