[racket] Problem with mzc v.5.1.1 and contracts

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Sep 20 11:59:07 EDT 2011

I'm not clear on your example in this case. Can you say more about what
"mime-parser.scm" contains as well as the native library that it's
using?

I have one wild guess, which is that the native library includes a call
to scheme_eval() on `struct:exn:fail'. If so, then maybe the current
namespace when the library is normally loaded happens to be initialized
with `racket/base' bindings, while the current namespace when the
module is loaded via `raco make' is in its default empty state. If that
wild guess happens to be right, then
scheme_builtin_value("struct:exn:fail") might be the right alternative.

At Tue, 20 Sep 2011 19:36:06 +0400, Timur Sufiev wrote:
> On 18.08.2011 10:40, Timur Sufiev wrote:
> 
> Matthew, another question about "raco make": when compiling via mzc, one 
> can specify so-library as module in require clause, e.g. (require (lib 
> "mzmimer" "jet")) and it is correctly resolved to 
> "/opt/dozor/racket/lib/racket/collects/jetinfo/compiled/native/i386-linux/3m/mz
> mimer.so" 
> and succesfully loaded. But the same module-path being processed by raco 
> make produces the following error:
>   /opt/dozor/racket/bin/raco make mime-parser.scm
> #f::0: compile: unbound identifier (and no #%top syntax transformer is 
> bound) in: struct:exn:fail
> 
>   === context ===
> standard-module-name-resolver
> /opt/dozor/racket/lib/racket/collects/compiler/cm.rkt:279:0: compile-zo*
> 
> Could you point out how to specify module-path to so-library to make 
> "raco make" compile it?
> > On 17.08.2011 16:58, Matthew Flatt wrote:
> > Thanks, Matthew, it works!
> >> I think that "ihash.scm" is being compiled twice: once when you use
> >> `mzc' on "ihash.scm" and again when using `mzc' on
> >> "config-enumerators.scm", assuming that you move the ".zo" files into
> >> place only after compiling both of them. Unfortunately, due to the way
> >> contracts expand, compiling a source file multiple times does not
> >> necessarily produce the example same result.
> >>
> >> It's simpler to use `raco make' (or `mzc --make' if you really want to
> >> use `mzc' for some reason) on just your main program file. The `raco
> >> make' command will automatically compile dependencies and leave ".zo"
> >> files in the right place (i.e., in a "compiled" subdirectory).
> >>
> >> At Tue, 16 Aug 2011 15:46:38 +0400, Timur Sufiev wrote:
> >>> Hi!
> >>>
> >>> I'm having a problem with byte-compiled modules and contracts. There 
> >>> are
> >>> 2 files, ihash.scm and config-enumerators.scm, both are compiled with
> >>>
> >>> 
> PLTCOLLECTS=/opt/dozor/racket/lib/racket/collects:/home/timur/develop/projects/
> d 
> >>>
> >>> ozor/build
> >>> LD_LIBRARY_PATH=/opt/dozor/racket/lib:$$LD_LIBRARY_PATH
> >>> /opt/dozor/racket/bin/mzc -z -d . $<
> >>> (working string from Makefile).
> >>>
> >>> Small piece of ihash.scm:
> >>>
> >>> #lang racket
> >>>
> >>> (define (ihash? ht)
> >>>     (and (hash? ht) (let ((index (hash-ref ht #f #f)))
> >>>                       (number? index))))
> >>>
> >>> (provide/contract (ihash-get (->  ihash? any/c any/c any/c)))
> >>>
> >>> (define (ihash-get ihash key default)
> >>>     (let ((value (hash-ref ihash key #f)))
> >>>       (if value (cdr value) default)))
> >>>
> >>> Small piece of config-enumerators.scm:
> >>>
> >>> #lang racket
> >>> (require (lib "ihash.scm" "lib"))
> >>> (define (section-replicable? section)
> >>>     (car (ihash-get section 'replicable? '(#f))))
> >>>
> >>> Before compilation both scm-s are put to
> >>> /home/timur/develop/projects/dozor/build/lib, compiled and then put to
> >>> /opt/dozor/smap/lib/lib/compiled. $HOME/.racketrc has the next command:
> >>> (current-library-collection-paths  (list* "/opt/dozor/smap/lib"
> >>> (current-library-collection-paths)))
> >>> Then i run /opt/dozor/racket/bin/mzscheme,
> >>> type (require (lib "config-enumerators.scm" "lib")) and get the
> >>> following error:
> >>> link: module mismatch, probably from old bytecode whose dependencies
> >>> have changed: variable not provided (directly or indirectly and at the
> >>> expected position) from module: "/opt/dozor/smap/lib/lib/ihash.scm"
> >>> accessed from module: "/opt/dozor/smap/lib/lib/config-enumerators.scm"
> >>> at source phase level: 0 in: provide/contract-contract-id-ihash-get.14
> >>>
> >>> Any ideas?
> >>>
> >>> -- 
> >>>
> >>> Best regards,
> >>> Sufiev Timur
> >>>
> >>> _________________________________________________
> >>>    For list-related administrative tasks:
> >>>    http://lists.racket-lang.org/listinfo/users
> >
> >
> 
> 
> -- 
> С уважением,
> Суфиев Тимур



Posted on the users mailing list.