Re: s48_extract_string?

Donald Allen <[email protected]>
Newsgroups gmane.lisp.scheme.scheme48
Message-ID <[email protected]>
On Tue, Mar 3, 2009 at 5:12 PM, Richard Kelsey <[email protected]> wrote:

>   Date: Tue, 3 Mar 2009 16:08:37 -0500
>    From: Donald Allen <[email protected]>
>
>    A few comments:
>
>   1. I'm failing to understand why what works in the REPL doesn't work when
>   loading from a file.  In other words, why is
>
>   ,open external-calls
>   ,open load-dynamic-externals
>
>   acceptable when typing to the REPL and not acceptable when loading a
> file?
>
> It is acceptable when typing to the command interpreter and
> not when loading a file.  Scheme48 provides no way to read
> commands from a file using the , syntax of the command
> interpreter.
>
>   2. As for whether it's a new language, that depends on how you define
>   "language" (sounds Clintonesque :-). Sure, it's Scheme syntax, but in
> order
>   to say what I want to say in normal Scheme acceptable at the REPL, e.g.,
>
>   (load-dynamic-externals "/home/dca/Scheme48/postgresql.so" #f #f #f)
>   (import-lambda-definition pg_open_connection (dbname))
>
>   I now need to wrap in a call to 'run' when loading a file. To me that's
> new
>   language -- things need to be said differently.
>
> No, you need to wrap them in a call to 'run' when loading
> them into the exec package.  Why would you expect to get the
> same behavior if you type
>
>  (load-dynamic-externals "/home/dca/Scheme48/postgresql.so" #f #f #f)
>
> into the REPL, which evaluates it in the user environment,
> and if you put it in a file and load it into the exec
> environment?


I wouldn't expect to get exactly the same behavior. In the first case, I'd
expect the dynamic-externals to be loaded into the user environment; in the
latter case, I'd expect them to be loaded into the exec environment. But why
would I expect to have to use different syntax in the two cases?

Also, I quote from the very example cited in the documentation, namely
scheme/vm/load-vm.scm:

(user)
(open 'ps-memory)
(open 'vm)
(open 'heap-init)
(open 'read-image)
(open 'memory-debug)

(run '
(define (start-vm image-file heap-size stack-size start-args)
  (reinitialize-memory)
  (s48-read-image image-file heap-size)
  (s48-initialize-vm (allocate-memory stack-size)
             (quotient stack-size 4))
  (s48-call-startup-procedure start-args
                  (vector-length start-args)))
)

(user) means we are now loading into the user environment, yes?  So the
function start-vm is going to end up in the user environment. Correct? So
again, my bottom-line question -- why does the define have to be wrapped in
a run (especially when the documentation of run tells you absolutely
nothing: "evaluates the expression, prints the result, and makes it the new
focus object"; well, typing an expression at the REPL does the same thing,
so what value is run adding? Can't tell from the manual.) when it lives in a
"command file" when that is unnecessary when typing at the REPL.



>  If you want the same behavior you need to load
> it into the same environment that the REPL uses.  Your command
> file has code that needs to be run in two different packages,
> the exec package and the user package.  There has to be some
> way to distinguish them.  The command interpreter does this
> by seeing the initial comma.


Exactly. And my contention is that the distinction ought to be made the same
way when loading from a file. They're bytes; they're just coming from a
different place.

>
>
> It would probably be clearer if the command interpreter didn't
> treat forms without initial commas as having a ,run in front
> of them.  If you had been required to put in all of the ,runs,
> the correspondence between the command interpreter and the
> exec package would have been clearer:
>  ,open external-calls
>  ,open load-dynamic-externals
>  ,run (load-dynamic-externals
>       "/home/dca/Finances/Invest/Options/Scheme48/postgresql.so" #f #f #f)
>  ,run (import-lambda-definition pg_open_connection (dbname))


Exactly the opposite. Leave the command interpreter as it is and use it to
read from files.

/Don

>
>
>
>                                            -Richard Kelsey
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.