This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: parameters not working?




On 05/13/2014 06:19 PM, mikel evins wrote:
My next issue: parameters appear to work fine in interactive sessions from loaded files, but not in required or compiled files.

More specifically, if I define a parameter like so:

(define foo (make-parameter #f))

at the top level of a source file and then require or compile that file, I will find at run time that foo is bound to a null pointer.

I assume that this is because requiring or compiling the source file does not execute the toplevel forms (unless it's the main file).

Am I guessing correctly about the execution model of required and compiled code? If so, how are parameters meant to be used in compiled code?

No, that is supposed to work - and seems to do so:

[bothner@toshie work1]$ cat ~/tmp/pfoo.scm
(define foo (make-parameter #f))
(format #t "foo (in pfoo): ~w~%" (foo))
[bothner@toshie work1]$ cat ~/tmp/pbar.scm
(require pfoo)
(format #t "foo (in pbar): ~w~%" (foo))
[bothner@toshie work1]$ bin/kawa  -C ~/tmp/pfoo.scm
(compiling /home/bothner/tmp/pfoo.scm to pfoo)
[bothner@toshie work1]$ bin/kawa  -C ~/tmp/pbar.scm
(compiling /home/bothner/tmp/pbar.scm to pbar)
[bothner@toshie work1]$ bin/kawa pbar
foo (in pfoo): #f
foo (in pbar): #f
[bothner@toshie work1]$ bin/kawa --main -C ~/tmp/pbar.scm
(compiling /home/bothner/tmp/pbar.scm to pbar)
[bothner@toshie work1]$ java pbar
foo (in pfoo): #f
foo (in pbar): #f

Could you write a simple test-program that shows the problem?
Note it should be complete and self-contained, and we need to
see the command-line(s) you use to compile and run it.

(Note I'm testing with the latest Kawa from Subversion.)
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]