Re: [Chicken-users] Exporting proc and macro that references it?
> >> I didn't get the error you're getting, but I think what you need is this > >> section from the manual: > >> > >> [snip] > >> > >> In other words, do (module embedded-test ((test register)) ...) > >> > >> I think it worked because the code you pasted in the mail also exported > >> REGISTER, which your real code perhaps does not? > > > > Hm, very strange. > > > > I'm literally testing with this (after your suggestion): > > > > (module embedded-test ((test register) register) > > (import chicken scheme) > > > > (define (register) #f) > > (define-syntax test (syntax-rules () ((test) (register > > ) > > Note: just using (test register) as export-list is fine, since > you are exporting register, anyway. You only need that if register > shouldn't be exported. OK. Makes perfect sense. > > And yet, /opt/chicken-4.5.0/bin/csc test.scm && ./test yields the error I > > quoted. :-/ Are you using 4.5.0? > > > > Your .setup file installs embedded-test as `syntax' (see property-list > in the invocation if `install-extension'), which means the extension > has no runtime part (and thus nothing is loaded at runtime to > provide the necessary runtime code). Remove the `(syntax)' and it > works. Ah! So that's what was breaking it, I see. Thanks for your help, it works now! Alejo. http://azul.freaks-unidos.net/ ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Exporting proc and macro that references it?
From: Alejandro Forero Cuervo Subject: Re: [Chicken-users] Exporting proc and macro that references it? Date: Mon, 5 Jul 2010 13:59:13 +0200 > >> I didn't get the error you're getting, but I think what you need is this >> section from the manual: >> >> [snip] >> >> In other words, do (module embedded-test ((test register)) ...) >> >> I think it worked because the code you pasted in the mail also exported >> REGISTER, which your real code perhaps does not? > > Hm, very strange. > > I'm literally testing with this (after your suggestion): > > (module embedded-test ((test register) register) > (import chicken scheme) > > (define (register) #f) > (define-syntax test (syntax-rules () ((test) (register > ) Note: just using (test register) as export-list is fine, since you are exporting register, anyway. You only need that if register shouldn't be exported. > > And yet, /opt/chicken-4.5.0/bin/csc test.scm && ./test yields the error I > quoted. :-/ Are you using 4.5.0? > Your .setup file installs embedded-test as `syntax' (see property-list in the invocation if `install-extension'), which means the extension has no runtime part (and thus nothing is loaded at runtime to provide the necessary runtime code). Remove the `(syntax)' and it works. cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Exporting proc and macro that references it?
Try (define-for-syntax (register) #f) --Stephen Sent from my Emacs On Mon, Jul 5, 2010 at 10:45 AM, Alejandro Forero Cuervo wrote: > Oh, BTW, the meta file has a "needs" entry that you'll probably want > to remove while testing this. > > Alejo. > http://azul.freaks-unidos.net/ > > ___ > Chicken-users mailing list > Chicken-users@nongnu.org > http://lists.nongnu.org/mailman/listinfo/chicken-users > ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Exporting proc and macro that references it?
Oh, BTW, the meta file has a "needs" entry that you'll probably want to remove while testing this. Alejo. http://azul.freaks-unidos.net/ ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Exporting proc and macro that references it?
> Yes, I'm using 4.5.0, but I didn't install the extension. I just ran > (use embedded-test) from the directory where I compiled it. > > Could you send me a tarball containing the full egg as-is, including the > setup and meta files? I'm attaching it to this message. Here is how I use it: tar xvfz embedded-test.tar.gz cd embedded-test /opt/chicken-4.5.0/bin/chicken-install /opt/chicken-4.5.0/bin/csc test.scm ./test Errors! :-( Thanks a lot for your help! :-) Alejo. http://azul.freaks-unidos.net/ embedded-test.tar.gz Description: Binary data ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Exporting proc and macro that references it?
On Mon, Jul 05, 2010 at 01:59:13PM +0200, Alejandro Forero Cuervo wrote: > The generated embedded-test.import.scm has this: > > (eval '(import chicken scheme)) > (##sys#register-compiled-module > 'embedded-test > (list '(register . embedded-test#register)) > '((register . embedded-test#register)) > (list (cons 'test (syntax-rules () ((test) (register) > (list)) > > And yet, /opt/chicken-4.5.0/bin/csc test.scm && ./test yields the error I > quoted. :-/ Are you using 4.5.0? Yes, I'm using 4.5.0, but I didn't install the extension. I just ran (use embedded-test) from the directory where I compiled it. Could you send me a tarball containing the full egg as-is, including the setup and meta files? Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Exporting proc and macro that references it?
> I didn't get the error you're getting, but I think what you need is this > section from the manual: > > [snip] > > In other words, do (module embedded-test ((test register)) ...) > > I think it worked because the code you pasted in the mail also exported > REGISTER, which your real code perhaps does not? Hm, very strange. I'm literally testing with this (after your suggestion): (module embedded-test ((test register) register) (import chicken scheme) (define (register) #f) (define-syntax test (syntax-rules () ((test) (register ) The setup file does this: /opt/chicken-4.5.0/bin/csi -bnq -setup-mode -e "(require-library setup-api)" -e "(import setup-api)" -e "(extension-name-and-version '(\"embedded-test\" \"\"))" embedded-test.setup /opt/chicken-4.5.0/bin/csc -feature compiling-extension -setup-mode-O2 -d1 -s embedded-test.scm -j embedded-test /opt/chicken-4.5.0/bin/csc -feature compiling-extension -setup-mode-O2 -d1 -c embedded-test.scm -unit embedded-test /opt/chicken-4.5.0/bin/csc -feature compiling-extension -setup-mode-O2 -d0 -s embedded-test.import.scm cp -r embedded-test.o /opt/chicken-4.5.0/lib/chicken/5/embedded-test.o chmod a+r /opt/chicken-4.5.0/lib/chicken/5/embedded-test.o rm -fr /opt/chicken-4.5.0/lib/chicken/5/embedded-test.import.so cp -r embedded-test.import.so /opt/chicken-4.5.0/lib/chicken/5/embedded-test.import.so chmod a+r /opt/chicken-4.5.0/lib/chicken/5/embedded-test.import.so rm -fr /opt/chicken-4.5.0/lib/chicken/5/embedded-test.so cp -r embedded-test.so /opt/chicken-4.5.0/lib/chicken/5/embedded-test.so chmod a+r /opt/chicken-4.5.0/lib/chicken/5/embedded-test.so chmod a+r /opt/chicken-4.5.0/lib/chicken/5/embedded-test.setup-info The generated embedded-test.import.scm has this: (eval '(import chicken scheme)) (##sys#register-compiled-module 'embedded-test (list '(register . embedded-test#register)) '((register . embedded-test#register)) (list (cons 'test (syntax-rules () ((test) (register) (list)) And yet, /opt/chicken-4.5.0/bin/csc test.scm && ./test yields the error I quoted. :-/ Are you using 4.5.0? Thanks a lot for your help! Alejo. http://azul.freaks-unidos.net/ ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Exporting proc and macro that references it?
On Mon, Jul 05, 2010 at 01:04:02PM +0200, Alejandro Forero Cuervo wrote: > > Am I doing something wrong? I've tried various combinations of 'use', > 'import', 'require-library', 'import-for-syntax' and > 'require-extension' to no avail. How does one make a macro transform > a form into a call to a procedure from its own module (that the module > exports)? I didn't get the error you're getting, but I think what you need is this section from the manual: "EXPORT may be a symbol or a list of the form (IDENTIFIER1 IDENTIFIER2 ...). In the former case the identifier given is exported from the module and can be imported at the toplevel or in other modules. The latter case exports IDENTIFIER1 (which should name a macro) and also arranges for the remaining identifiers in the list to be visible in the expansion of the macro (this is a hint to the module expander to export bindings referenced by syntax-definitions which make use of them, but which would normally be internal to the module - which gives more opportunities for optimization)." --- http://chicken.wiki.br/man/4/Modules%20and%20macros In other words, do (module embedded-test ((test register)) ...) I think it worked because the code you pasted in the mail also exported REGISTER, which your real code perhaps does not? Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Exporting proc and macro that references it?
I have a module embedded-test that exports a procedure called 'register' and a macro called 'test' that transforms a form into a call to 'register'. It looks like this (I'm simplifying a lot): (module embedded-test (test register) (import chicken scheme) (define (register) #f) (define-syntax test (syntax-rules () ((test) (register ) I install the extension and can use it from csi without problems but when I try the following compiled program, (use embedded-test) (test) I get: Error: unbound variable: embedded-test#register Call history: embedded-test#register <-- Am I doing something wrong? I've tried various combinations of 'use', 'import', 'require-library', 'import-for-syntax' and 'require-extension' to no avail. How does one make a macro transform a form into a call to a procedure from its own module (that the module exports)? In case the answer is of the form "Chicken does not support this, what are you trying to do?", what I'm trying to do is let the programmer say things like (test (+ 2 3) 5) and have that transformed into something like (register-test '(+ 2 3) (lambda () (+ 2 3)) (lambda () 5) equal?). If there are better ways to do this, I'm all ears. For my format-compiler, I workarounded the let-optionals bug by renaming 'rest' to 'rest-xrenamed' throughout my code but now I'm stuck with this problem. Any help would be appreciated. Thanks! Alejo. http://azul.freaks-unidos.net/ ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users