[Chicken-users] CSI and CSC do not do the same for syntax definitions

2012-01-17 Thread obscuroloconato
I have two files which are run correctly by the interpreter but the
compiled version fails to run:

$ csi -i -s x.scm
x
y

$ csc x.scm  ./x
x

Error: unbound variable: y

Is this the intended behavior?

This is x.scm:

(define-syntax x
  (syntax-rules ()
((_) (display x\n
(load ./y.scm)
(x)
(y)

And this is y.scm:

(define-syntax y
  (syntax-rules ()
((_) (display y\n

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] CSI and CSC do not do the same for syntax definitions

2012-01-17 Thread Alaric Snell-Pym
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 01/17/2012 09:35 AM, obscurolocon...@googlemail.com wrote:
 I have two files which are run correctly by the interpreter but the
 compiled version fails to run:

 $ csi -i -s x.scm
 x
 y

 $ csc x.scm  ./x
 x

 Error: unbound variable: y

 Is this the intended behavior?

Yes. The effect of load is, necessarily, at run time. When run in csi,
the load can therefore happen immediately, and csi gets the syntax
definition of y. When compiled, the load happens not at compile time but
at run time, when it's too late to expand any syntax; the compiler has
compiled in a reference to y as a (initially unbound) variable in the
hope that loading y.scm will assign a value to y. However, syntax
definitions are not value assignments, as they are compile-time beasts!

ABS

- --
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8VUYMACgkQRgz/WHNxCGosyACcCY5CpL+aUap/omyXLL9aR0yb
yLYAn1xr6cgmt05/9zW5/vkYBfgx3dgX
=gvpQ
-END PGP SIGNATURE-

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users