[Larceny-users] Larceny basics
Dan Muresan
danmbox at gmail.com
Sat Sep 1 15:30:11 EDT 2007
Felix wrote:
> The experiments you list all extend the run-time syntactic environment,
> not the compile-time environment. This means that they would have the
> same problem as the one I described with my srfi-8 example.
Oh, I forgot... OK, I've tried compiling, but now I get a weird error,
even for a simple srfi-8 test: "Error: environment-get-cell: denotes a
macro: ...".
There are the 3 files, req.sch, xsrfi-8.sch and test.sch. The exercise
is to get test.sch to compile and load correctly without ever explicitly
loading xsrfi-8:
;; ---8x---
;; req.sch
(require 'srfi-1)
(define (read-file f)
(define (read-stdin)
(unfold-right eof-object? values (lambda (x) (read)) (read)))
(with-input-from-file f read-stdin))
(define-syntax req-for-stx
(syntax-rules ()
((_ file) (for-each macro-expand (read-file file)))))
;; ---8x---
;; ---8x---
;; xsrfi-8.sch
(define-syntax xreceive
(syntax-rules ()
((_ formals expression body ...)
(call-with-values (lambda () expression)
(lambda formals body ...)))))
;; ---8x---
;; ---8x---
;; test.sch
(req-for-stx "xsrfi-8.sch")
(define (successor x) (values x (+ x 1)))
(xreceive (y z) (successor 3)
(display (list y z))
(newline))
;; ---8x---
And here's what happens:
muresan at home:~$ larceny
Larceny v0.94 "Doomsday Device" (Jul 2 2007 07:53:36,
precise:Linux:unified)
larceny.heap, built on Mon Jul 2 08:04:08 EDT 2007
> (load "req.sch")
> (compile-file "test.sch")
muresan at home:~$ larceny
Larceny v0.94 "Doomsday Device" (Jul 2 2007 07:53:36,
precise:Linux:unified)
larceny.heap, built on Mon Jul 2 08:04:08 EDT 2007
> (load "req.sch")
> (load "test.fasl")
Error: environment-get-cell: denotes a macro: xreceive
> Maybe I misread your message where you described Chicken's
> require-for-syntax. Does Chicken's require-for-syntax extend the
> syntactic environment at run-time, or at compile-time?
The compile-time environment:
http://galinha.ucpel.tche.br:8080/Unit%20eval#require
(the Chicken wiki has moved around so much that Google doesn't index it
well)
Best,
Dan
More information about the Larceny-users
mailing list