[plt-scheme] Separate compilation

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Fri Jun 11 09:33:51 EDT 2004

As I write earlier I can compile my module in one
go and get the right result:

   [soegaard at commander plt]$ mzc --exe main main.scm
   MzScheme compiler (mzc) version 205, Copyright (c) 1996-2003 PLT
   [output to "main"]
   [soegaard at commander plt]$ ./main
   3.141592653589793
   1.4142135623730951
   4.555806215962888

However I claimed that the PLT module system also handled
the case of separate compilation.

I have tried demonstrating this with the interaction below,
but I like to know whether it actullly show what I think it
shows. More specifically I need to knoe whether
the (require main) load the compiled version of the main module
or whether mzscheme compiles it itself.

   [soegaard at commander plt]$ mzc --object *.scm
   MzScheme compiler (mzc) version 205, Copyright (c) 1996-2003 PLT
   "compile-time.scm":
    [output to "./compile-time.o"]
   "constants.scm":
    [output to "./constants.o"]
   "load.scm":
    [output to "./load.o"]
   "main.scm":
    [output to "./main.o"]
   "misc.scm":
    [output to "./misc.o"]
   "roots.scm":
    [output to "./roots.o"]
   "trig.scm":
    [output to "./trig.o"]

   [soegaard at commander plt]$ mzc --link-extension compile-time.kp compile-time.o constants.kp
   constants.o trig.kp trig.o roots.kp roots.o misc.kp misc.o main.kp main.o

   MzScheme compiler (mzc) version 205, Copyright (c) 1996-2003 PLT
   "/home/soegaard/macros-and-modules/plt/_loader.c":
    [output to "/home/soegaard/macros-and-modules/plt/_loader.so"]

   [soegaard at commander plt]$ mzscheme
   Welcome to MzScheme version 205, Copyright (c) 1995-2003 PLT
   > (load/use-compiled "main.scm")
   > (require main)          ; <- Is this using compiled version?
   3.141592653589793
   1.4142135623730951
   4.555806215962888

Using another method I got strange results:

   [soegaard at commander plt]$ mzc --object *.scm
   MzScheme compiler (mzc) version 205, Copyright (c) 1996-2003 PLT
   "compile-time.scm":
    [output to "./compile-time.o"]
   "constants.scm":
    [output to "./constants.o"]
   "load.scm":
    [output to "./load.o"]
   "main.scm":
    [output to "./main.o"]
   "misc.scm":
    [output to "./misc.o"]
   "roots.scm":
    [output to "./roots.o"]
   "trig.scm":
    [output to "./trig.o"]
   [soegaard at commander plt]$ mzc --link-extension compile-time.kp compile-time.o constants.kp
    constants.o trig.kp trig.o roots.kp roots.o misc.kp misc.o main.kp main.o

   MzScheme compiler (mzc) version 205, Copyright (c) 1996-2003 PLT
   "/home/soegaard/macros-and-modules/plt/_loader.c":
    [output to "/home/soegaard/macros-and-modules/plt/_loader.so"]
   [soegaard at commander plt]$ mzscheme
   Welcome to MzScheme version 205, Copyright (c) 1995-2003 PLT
   > (load/use-compiled "misc.scm")
   > (contant pi)
   reference to undefined identifier: contant
   > (constant pi)
   4.555806215962888
   > (constant root2)
   4.555806215962888
   > (constant pi+root2)
   4.555806215962888
   > (constant e)
   4.555806215962888
   > (constant this-ought-to-give-an-error)
   4.555806215962888

Suddenly all uses of constant give the same number???
And it doesn't give any error when given names of undefined
constants.

Have I misuderstood the use of (load/use-compuled "misc.scm") ?

-- 
Jens Axel Søgaard





Posted on the users mailing list.