[Larceny-users] library form for gl.scm

William D Clinger will at ccs.neu.edu
Thu Feb 5 11:39:32 EST 2009


Eduardo Cavazos wrote:
> If I load it via either one of these:
>
> ~ # larceny -- /scratch/_gl-test-case-a.scm
>
> ~ # larceny -err5rs -- /scratch/_gl-test-case-a.scm
>
> I get this error:
>
> ERROR detected during macro expansion:
> Definition out of context
> (define libGL (foreign-file "libGL.so.1"))

Sorry, I had missed that you were loading the file
via Larceny's -- hack.  That hack works only in R5RS
and ERR5RS modes; in either mode the file is loaded
as R5RS code, so the library form looks like a call
to a procedure named "library".  Definitions are
illegal in the argument positions of procedure calls,
so you're getting an R5RS syntax error.

Now that all of the forms in the body of the library
are definitions, you should be able to load the file
into ERR5RS mode like this:

    # larceny -err5rs
    ERR5RS mode (no libraries have been imported)

    > (import (rnrs) (larceny load))
    > (load "/scratch/_gl-test-case-a.scm")

You could also rename the file so it ends with .sls,
place it in a directory named larceny, and add the
parent of the larceny directory to your library path.
Then you could import it like this:

    # larceny -path <dir> -err5rs
    ERR5RS mode (no libraries have been imported)

    > (import (rnrs) (larceny gl))

We should probably add a library macro to Larceny's
standard heap, and define that macro so the error
message will tell you the problem came from trying
to use the library syntax in R5RS mode.

Will



More information about the Larceny-users mailing list