Hi there, I decided that it would be good to make sure that I am up-to-date with Gambit 4.4 before I posted my web framework here for those who have expressed an interest and I am finding a destructive interaction when using the c-lambda form.
With the code in the sequel and Gambit 4.4.0, if I compile thusly:
$ gsc -:s -link bug.gambit *** ERROR IN MAP -- invalid syntax ()
but it compiles fine if I omit the -:s option. Now obviously, the example does not require syntax-rules macros, but the full framework certainly does. Is there a known incompatibility here? The text concerning define-syntax hints at such a possibility, but the actual interaction is unclear.
david
Afficher les réponses par date
On 2-Feb-09, at 6:57 AM, David Rush wrote:
Hi there,
I decided that it would be good to make sure that I am up-to-date with Gambit 4.4 before I posted my web framework here for those who have expressed an interest and I am finding a destructive interaction when using the c-lambda form.
With the code in the sequel and Gambit 4.4.0, if I compile thusly:
$ gsc -:s -link bug.gambit *** ERROR IN MAP -- invalid syntax ()
but it compiles fine if I omit the -:s option. Now obviously, the example does not require syntax-rules macros, but the full framework certainly does. Is there a known incompatibility here? The text concerning define-syntax hints at such a possibility, but the actual interaction is unclear.
If you look at the manual under "define-syntax" you will see:
Note that this implementation of syntax-case does not support special forms that are specific to Gambit.
And c-lambda is one of those Gambit specific forms. The Hieb and Dybvig portable syntax-case implementation which is used by Gambit does not know that c-lambda is a special form, so when it sees (c- lambda () ...) it thinks this is a function call and () is an expression, which is illegal in Scheme (you need to quote the () if it was an expression). That's why you get an error message. Note that it is the portable syntax-case implementation that is detecting this error.
I'll see what I can do to extend the portable syntax-case implementation for Gambit. Last time I tried I remember a problem in the bootstrap process.
Note that for your specific need for this code, I'm curious why you need to interface to the C timeval structure. Can't you implement timing using (current-time) and (timeout->time timeout)?
Marc
On 4-Feb-09, at 7:45 AM, Marc Feeley wrote:
I'll see what I can do to extend the portable syntax-case implementation for Gambit. Last time I tried I remember a problem in the bootstrap process.
Here's a solution. At the end of lib/psyntax73.ss add these lines:
(define-syntax future (syntax-rules () ((_ rest ...) (##future rest ...))))
(define-syntax c-define-type (syntax-rules () ((_ rest ...) (##c-define-type rest ...))))
(define-syntax c-declare (syntax-rules () ((_ rest ...) (##c-declare rest ...))))
(define-syntax c-initialize (syntax-rules () ((_ rest ...) (##c-initialize rest ...))))
(define-syntax c-lambda (syntax-rules () ((_ rest ...) (##c-lambda rest ...))))
(define-syntax c-define (syntax-rules () ((_ rest ...) (##c-define rest ...))))
(define-syntax declare (syntax-rules () ((_ rest ...) (##declare rest ...))))
(define-syntax namespace (syntax-rules () ((_ rest ...) (##namespace rest ...))))
Then
% cd lib % ./syntax-case-build
This will generate from psyntax73.ss a new "syntax-case.scm" file with support for some of the Gambit specific special forms. Then "make install" from the root.
I have tested this very lightly. I'd like to know if you encounter any problems before I commit this patch.
Marc