|
From: | Daniel Leslie |
Subject: | Re: [Chicken-users] Some syntax help? |
Date: | Sat, 2 May 2015 08:49:09 -0700 |
Hi Chickeners!
Around two weeks ago I received a bug report that the monad egg wasn't
working in CSC. This turned out to be the result of a syntax error, and
though I've greatly simplified the syntax and narrowed the issue
considerably, I find myself stuck in a corner while surrounded by wet
paint.
Working branch is here:
https://github.com/dleslie/monad-egg/tree/compiler-import-bug
The issue is thus: the egg does some heavy lifting of syntax transforms,
and there exists a utility such that a user might bind new symbols while
within the quoted syntax of a stack of transformers. It looks like this:
(do <state>
(/m! put 99)
(x <- (/m get))
(return x))
Which would expand to something similar to:
(<state>-bind
(<state>-put 99)
(<state>-bind
(<state>-get)
(lambda (x)
(<state>-unit x))))
I think; it's early. ;)
Anyhow, notice that the /m and /m! transforms occur within the do
syntax; the do syntax transforms through do-using, %unroll-do-using, and
finally to using; where they're defined dynamically within a quoted
syntax block.
Here's the wierdness: this works magnificently in CSI, but fails in CSC.
Moreover, if I replace /m! with a broken variant then /m works great in
both CSI and CSC! I know, it doesn't make much sense to me either. My
best guess is that /m! failing somehow short-circuits a code path in the
compiler and so allows /m to function as I expect.
The correct code that CSC breaks on:
https://github.com/dleslie/monad-egg/blob/compiler-import-bug/monad.scm#L58-L61
And test output:
https://gist.github.com/71cc934fbc9fc7fa2d86
The incorrect code that CSC allows other things to work on:
https://github.com/dleslie/monad-egg/blob/compiler-import-bug/monad.scm#L63-L66
And test output:
https://gist.github.com/d0c276f7ed243d79166b
Any thoughts would be appreciated. :D
Thanks!
--
-Dan Leslie
[Prev in Thread] | Current Thread | [Next in Thread] |