This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Portable Syntax Case


Adam Warner wrote:

I've been trying to bootstrap R. Kent Dybvig and Oscar Waddell's
portable syntax case code in userspace. The code is permissively
licensed for incorporation into any implementation:
<http://www.scheme.com/syntax-case/>

I've attempted to follow the instructions in...
<http://www.scheme.com/syntax-case/psyntax.ss>

...in order to load...
<http://www.scheme.com/syntax-case/psyntax.pp>

I had to fix Kawa's potential number reader because it was mistaking
symbols prefixed with an underscore and followed by number characters as
"not a valid number" instead of symbols:

The existing code follow the Common Lisp "potential number" syntax, which does exclude some valid Scheme identifiers. I think the followin is a slightly more conservative patch:

Index: LispReader.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/kawa/lispexpr/LispReader.java,v
retrieving revision 1.16
diff -u -r1.16 LispReader.java
--- LispReader.java	2 Oct 2003 17:57:12 -0000	1.16
+++ LispReader.java	19 Apr 2004 06:52:54 -0000
@@ -293,7 +293,12 @@
 	    if (i == start)
 	      return false;
 	  }
-	else if (ch != '.' && ch != '_' && ch != '^')
+	else if (ch == '_' || ch == '^')
+ 	  {
+	    if (i == start /* && ! common_lisp */)
+	      return false;
+	  }
+	else if (ch != '.')
 	  return false;
       }
     return sawDigits > 0;

With this fixed and Kawa recompiled I have now struck this error when
attempting to load psyntax.pp:

java.lang.VerifyError: (class: atInteractiveLevel$frame, method:
lambda186genSyntaxCase669 signature:
(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Incompatible type for getting or setting field
        at atInteractiveLevel.apply(psyntax.pp:6)

I have duplicated this. It looks like a bug in using the wrong "closure object":

Method name:"lambda186genSyntaxCase669" public Signature: (java.lang.Object,
java.lang.Object,java.lang.Object,java.lang.Object)java.lang.Object
...
100: aload_0
101: astore 9
...
114: aload 9
116: getfield <Field atInteractiveLevel$frame43.lambda$Fn87 gnu.expr.ModuleMethod>
...
This load register 0 which has the "this" pointer, and thus
has type atInteractiveLevel$frame into reister 9, and then
uses register 9 as if it has type atInteractiveLevel$frame43.


The closure handling code is unfortunatly some of the more
complicated and fragile parts of Kawa, because it supports
a number of different strategies.

I've tried to figure out psyntax.scm in the past, and given
up.  I don't like the strategy of trying to compile psyntax.pp
because it would be hard to integrate that cleanly into Kawa.
Instead, I'd rather "reimplement" the concepts of psyntax.scm
using java code.  This would be a lot more efficient and more
integrated, and would be allow for easier bootstrapping.
However, I find the algorithm difficult to understand and
unintuitive, and I've never put in the time to try to really
understand it.

I also find syntax-case very poorly specified.  All I can find
are examples of its use, but no real semantic specification,
formal or informsl.  For example, something as obvious as
what identifiers are valid in macro transformers isn't even
mentioned anywhere I've seen.  This has reduced my incentive
to try to understand it and get it working ...

On the other hand, it *would* be nice to have syntax-case
working fully.  (A small subset of syntax-case does work.)
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]