[Chicken-users] chicken-spock and 'load'
I am probably missing something very obvious, but I cannot seem to figure out how to load one file (Scheme source) in another when using chicken-spock. I'd be grateful for any pointers. Should I be using some other mechanism to pull in code and libraries? (What I'm hoping to do is, for example, use portable SRFI implementations within my code destined for Javascript via chicken-spock.) For example, I have in file t.scm: (load "t2.scm") (define t t2) (print t) and in t2.scm: (define t2 't2) Running chicken-spock t.scm gives: /* CODE GENERATED BY SPOCK 0 */ var t3 = function (k1) { return ___load(k1, "t2.scm"); }; SPOCK.run(t3); var t5 = function (k2) { ___t = ___t2;// set! t return ___print(k2, ___t); }; SPOCK.run(t5); SPOCK.flush(); /* END OF GENERATED CODE */ which generates Javascript errors about ___t2 being undefined and syntax error in t2.scm. I'll take this opportunity to wish everyone the season's best. Regards, -chaw ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] chicken-spock and 'load'
Sudarshan S Chawathe scripsit: > I am probably missing something very obvious, but I cannot seem to > figure out how to load one file (Scheme source) in another when using > chicken-spock. I'd be grateful for any pointers. Scheme `load` is a procedure; that is, it is executed at run time. Spock is an offline compiler, so there is no way to load Scheme code (as opposed to JavaScript code) into a running Spock program. As far as I know, Spock doesn't implement `include` either, which would be a compile-time action. > (What I'm hoping to do is, for example, use portable SRFI > implementations within my code destined for Javascript via > chicken-spock.) All I can suggest is that you compile them separately and then concatenate the resulting JavaScript files. However, if the SRFIs include macros, those macros won't be available to your code. -- John Cowan http://www.ccil.org/~cowanco...@ccil.org If a soldier is asked why he kills people who have done him no harm, or a terrorist why he kills innocent people with his bombs, they can always reply that war has been declared, and there are no innocent people in an enemy country in wartime. The answer is psychotic, but it is the answer that humanity has given to every act of aggression in history. --Northrop Frye ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] chicken-spock and 'load'
Sudarshan S Chawathe scripsit: > The 'load' not working makes sense now; thanks for the reminder! It > seems odd that 'include' or something similar isn't available. Apparently you are just supposed to supply multiple files of Scheme code on the Spock command line. -- John Cowan http://www.ccil.org/~cowanco...@ccil.org He played King Lear as though someone had played the ace. --Eugene Field ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] chicken-spock and 'load'
> From: John Cowan> Scheme `load` is a procedure; that is, it is executed at run time. > Spock is an offline compiler, so there is no way to load Scheme code > (as opposed to JavaScript code) into a running Spock program. As far > as I know, Spock doesn't implement `include` either, which would be a > compile-time action. The 'load' not working makes sense now; thanks for the reminder! It seems odd that 'include' or something similar isn't available. > > (What I'm hoping to do is, for example, use portable SRFI > > implementations within my code destined for Javascript via > > chicken-spock.) > > All I can suggest is that you compile them separately and then concatenate > the resulting JavaScript files. However, if the SRFIs include macros, > those macros won't be available to your code. Thanks for the suggestion. I think I'll try to cobble soemthing together using the procedural interface to spock (instead of just relying on the command-line compile-spock, as I have been doing so far). The 'spock' procedure includes an 'import' option, but so far I haven't figured out how to use it for the above purposes. I'll have to dig a bit deeper there. Regards, -chaw ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users