jeffbz
2008-01-25 15:48:05 UTC
Here's a patch for the jscheme compiler. I found that (and ...) gets compiled
to return #t when all arguments are true rather than the value of the last
argument like it should. Also, I added a hack that provides a
'load-when-compile' form that evaluates definitions in a file at compile
time. I needed this to make some functions available for compile-time
macroexpansion (this fixes the problem I posted about before). There's also
a similar modification that makes the compiler's read pass descend into
(load)ed files. I can see that not everybody might want this behavior, but
it made sense to me since otherwise you'd be loading interpreted definitions
from compiled code instead of just compiling everything.
This applies to src/jsint/compiler/Compiler.scm in jscheme-7.2
56a57,66
< (let ((PROG (let readlist
< ((L (open-input-file fullfilename)))
< (let ((a (read L)))
< (if (eof-object? a) ()
< (cons a (readlist L))))))
< (PATH_CLASSNAME
---
< `(if ,(first args) (and ,@(rest args)) #f))))
---
to return #t when all arguments are true rather than the value of the last
argument like it should. Also, I added a hack that provides a
'load-when-compile' form that evaluates definitions in a file at compile
time. I needed this to make some functions available for compile-time
macroexpansion (this fixes the problem I posted about before). There's also
a similar modification that makes the compiler's read pass descend into
(load)ed files. I can see that not everybody might want this behavior, but
it made sense to me since otherwise you'd be loading interpreted definitions
from compiled code instead of just compiling everything.
This applies to src/jsint/compiler/Compiler.scm in jscheme-7.2
56a57,66
(define (readlist fullfilename)
; make defs available to compiler
(let ((L (open-input-file fullfilename)))
(let loop ((a (read L)))
(cond ((eof-object? a) ())
((and (pair? a) (eq? (car a) 'load))
(append (readlist (cadr a)) (loop (read L))))
((and (pair? a) (eq? (car a) 'load-when-compile))
(load (cadr a)) (loop (read L)))
(else (cons a (loop (read L))))))))
60,65c70,71; make defs available to compiler
(let ((L (open-input-file fullfilename)))
(let loop ((a (read L)))
(cond ((eof-object? a) ())
((and (pair? a) (eq? (car a) 'load))
(append (readlist (cadr a)) (loop (read L))))
((and (pair? a) (eq? (car a) 'load-when-compile))
(load (cadr a)) (loop (read L)))
(else (cons a (loop (read L))))))))
< (let ((PROG (let readlist
< ((L (open-input-file fullfilename)))
< (let ((a (read L)))
< (if (eof-object? a) ()
< (cons a (readlist L))))))
< (PATH_CLASSNAME
---
(let ((PROG (readlist fullfilename))
(PATH_CLASSNAME
221c228,230(PATH_CLASSNAME
< `(if ,(first args) (and ,@(rest args)) #f))))
---
(if (null? (cdr args))
(car args)
(car args)
--
View this message in context: http://www.nabble.com/patch%3A-compiler-fix-for-AND%2C-add-load-when-compile-tp15090512p15090512.html
Sent from the JScheme - User mailing list archive at Nabble.com.
View this message in context: http://www.nabble.com/patch%3A-compiler-fix-for-AND%2C-add-load-when-compile-tp15090512p15090512.html
Sent from the JScheme - User mailing list archive at Nabble.com.