bugKawa - Bugs: bug #14218, Exception compiling define-syntax

 
 

bug #14218: Exception compiling define-syntax

Submitter:  Dean Ferreyra <dferreyra>
Submitted:  Thu 18 Aug 2005 05:10:43 PM UTC
   
 
Category:  Code generation Severity:  3 - Normal
Item Group:  Feature Request Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 10 Feb 2006 10:20:05 PM UTC, comment #3: 

I've extended the interpreter to handle let and (most) lambda forms, so you can now use syntax-transforing functions in the same module as they are defined.

So this example now works.

Per Bothner <bothner>
Group administrator
Thu 18 Aug 2005 06:40:04 PM UTC, comment #2: 

Ah, I see.  Sorry, I didn't recognize this as the same issue.

No need to bump priorities.  When I added this, it was more so that it wouldn't be forgotten.  But there's nothing to forget as it's a known issue.

Thanks!

Dean Ferreyra <dferreyra>
Thu 18 Aug 2005 06:24:30 PM UTC, comment #1: 

Kawa has never supported procedural macros (as opposed to syntax-rules) being used in the same module as they are defined.  The reason is that lambda expressions are always compiled, never interpreted, and there is no mechanism for compiling  a modules in different pieces.

There are two possible solutions:
(1) Extend the interpreter to handle lambda and let forms.
(2) Implement a mechanism to split a module into sub-modules that can be compiled in stages.  This could be done automatically or manually, using something like Common Lisp's eval-when.

Neither is planned for Kawa 1.8, but I had planned on doing (1) fairly soon.  I think it would be fairly easy; it's mainly an issue of deciding on a suitable data structure for interpreted lexical environments (frames and closures).  I can bump up the priority if you'd like.

Per Bothner <bothner>
Group administrator
Thu 18 Aug 2005 05:10:43 PM UTC, original submission:  

We're getting an exception compiling macros and their uses, like this:

  (module-static #t)
 
  (define-syntax foo
    (lambda (x)
      (syntax #f)))
 
  (foo)

I've copied in the exception below.

The problem seems to come from trying to use this style of macro in the same file it's defined.  If I move the use of foo to a different file, everything compiles (and runs) fine.

----------------------------------------

% CLASSPATH=~/kawa/cvs/kawa-pure-build/kawa-1.8beta.jar java kawa.repl -C syn.scm
(compiling syn.scm)
java.lang.RuntimeException: internal error - class gnu.expr.LambdaExp.eval called
        at gnu.expr.Expression.eval(Expression.java:15)
        at gnu.expr.ApplyExp.eval(ApplyExp.java:59)
        at kawa.lang.Translator.check_if_Syntax(Translator.java:218)
        at kawa.lang.Translator.scanForm(Translator.java:896)
        at gnu.kawa.lispexpr.LispLanguage.parse(LispLanguage.java:59)
        at gnu.expr.Language.parse(Language.java:464)
        at kawa.lang.CompileFile.read(CompileFile.java:37)
        at kawa.lang.CompileFile.read(CompileFile.java:20)
        at kawa.lang.CompileFile.compile_to_files(CompileFile.java:65)
        at kawa.repl.processArgs(repl.java:407)
        at kawa.repl.main(repl.java:728)
java.lang.RuntimeException: internal error - class gnu.expr.LambdaExp.eval called
        at gnu.expr.Expression.eval(Expression.java:15)
        at gnu.expr.ApplyExp.eval(ApplyExp.java:59)
        at kawa.lang.Translator.check_if_Syntax(Translator.java:218)
        at kawa.lang.Translator.rewrite_pair(Translator.java:280)
        at kawa.lang.Translator.rewrite_with_position(Translator.java:806)
        at kawa.lang.Translator.rewrite(Translator.java:568)
        at kawa.lang.Translator.rewriteInBody(Translator.java:409)
        at kawa.lang.Translator.rewriteBody(Translator.java:1069)
        at kawa.lang.Translator.makeBody(Translator.java:1076)
        at kawa.lang.Translator.finishModule(Translator.java:1192)
        at gnu.kawa.lispexpr.LispLanguage.parse(LispLanguage.java:65)
        at gnu.expr.Language.parse(Language.java:464)
        at kawa.lang.CompileFile.read(CompileFile.java:37)
        at kawa.lang.CompileFile.read(CompileFile.java:20)
        at kawa.lang.CompileFile.compile_to_files(CompileFile.java:65)
        at kawa.repl.processArgs(repl.java:407)
        at kawa.repl.main(repl.java:728)
<unknown>:0: unable to evaluate macro for foo
syn.scm:7:1: unable to evaluate macro for foo

Dean Ferreyra <dferreyra>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 6 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-02-10 bothner StatusPostponed Fixed
    Open/ClosedOpen Closed
2005-08-18 bothner CategoryScheme language Code generation
    Item GroupCompile-time exception Feature Request
    StatusNone Postponed
    Assigned toNone bothner

Back to the top

Powered by Savane 3.13-4b48.
Corresponding source code