scsh-users
[Top] [All Lists]

Re: load

To: walter@pelissero.org ("Walter C. Pelissero")
Subject: Re: load
From: Martin Gasbichler <gasbichl@informatik.uni-tuebingen.de>
Date: 27 Nov 2001 12:39:24 +0100
Cc: scsh-news@zurich.ai.mit.edu
Sender: gasbichl@informatik.uni-tuebingen.de
>>>>> "WP" == Walter C Pelissero <walter@pelissero.org> writes:

WP> Martin Gasbichler writes:
>> So, I still don't see your problem...

WP> I have to confess I haven't been trying the interpreted version.  So
WP> here is my test:

WP> hyde259% cat test1.scm
WP> #!/usr/local/bin/scsh \
WP> -dm -o program -e main -s
WP> !#

WP> (define-structure program
WP>   (export foo main)
WP>   (open scheme scsh)
WP>   (begin

>> (define *stuff* '())

>> (define (foo x)
>> (set! *stuff* (cons x *stuff*)))

>> (define (bar)
>> (load "test2.scm"))

>> (define (main args)
>> (bar)
>> (display *stuff*)
>> (newline))))
WP> hyde260% cat test2.scm
WP> (foo 'a)
WP> (foo 'b)
WP> (foo 'c)
WP> hyde261% ./test1.scm
WP> test2.scm 
WP> (c b a)
WP> hyde262% make test1
WP> ./make-scsh-image.scm test1.scm -lm modules.scm
WP> hyde263% ./test1
WP> test2.scm 
WP> Error: undefined variable
>> foo
>> (package initial-system)
WP> Undefined: (foo)
WP> hyde264% 

WP> I begin to suspect the problem might be in make-scsh-image.scm which
WP> (according to the manual) does a simple:
WP> (run (| (begin
>> (format #t "(dump-scsh-program main \"~a\") (exit)" temp-file))
>> (scsh ,@args -lm ,source-file -o program))
>> (> /dev/null))

WP> where args is '(-lm modules.scm) and source-file is test1.scm.  Then
WP> it adds

WP> "#!/usr/local/lib/scsh/scshvm \\\n-o /usr/local/lib/scsh/scshvm -i\n!#\n"

WP> to fix the header.

What is modules.scm? 

It looks as DUMP-SCSH-PROGRAM doesn't initialize the environment of
the run-time system correctly. As a consequence
INTERACTION-ENVIRONMENT is set to the wrong package. There is no
simple fix but it's on my TODO list.

WP> Wouldn't this hard code source.scm in the compiled code? (yes, I'm
WP> generating scsh images for speed)
>> 
>> Okay, I see. But the code of source.scm will only be compiled and
>> stored in the image if you load/open the module SOURCE before you dump the
>> image. Otherwise the compiler will not look into the module's code.

WP> How would you delay the opening of SOURCE?

I think this is difficult considering the way you start scsh. You
would need the -o switch which is not available if you start the VM
directly.

-- 
Martin

<Prev in Thread] Current Thread [Next in Thread>