[plt-scheme] dynamic-require and contracted code?

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Thu Oct 27 15:43:00 EDT 2005

Hi everyone,

I'm trying to write a small timer program to test different
implementations of a function.  Each implementation lives in a separate
module, and I thought I might write something like this to grab at the
implementation's function:

;;;;;;
(define (extract-make-suffix-tree module-filename)
  (dynamic-require module-filename 'make-suffix-tree))
;;;;;;


Unfortunately, this gives an error:

;;;;;;
> (extract-make-suffix-tree "brute-force.ss")
dynamic-require: name is provided as syntax: make-suffix-tree by module:
|,/Users/dyoo/work/aztec/scratch/plt/suffixtree/brute-force|
;;;;;;


where my brute-force.ss looks like:

;;;;;;
(module brute-force mzscheme
  (require (lib "contract.ss"))

  (provide/contract (make-suffix-tree (-> label? tree?)))
  (define make-suffix-tree ...))
;;;;;;


I understand that the contract is binding make-suffix-tree as exported
syntax, so that's what's causing the issue with dynamic-require. I could
temporarily turn off the contract while I do performance tests, but that
feels a little unsatisfactory too.

The best solution I can think of so far is to provide two entry points
into the implementation, one with contracts, and one without.  Something
like:

;;;;;;
(module brute-force mzscheme
  (require (lib "contract.ss"))

  (provide/contract (make-suffix-tree (-> label? tree?)))
  (provide make-suffix-tree/without-contract)

  (define make-suffix-tree/without-contract ...)
  (define make-suffix-tree make-suffix-tree/without-contract))
;;;;;;


But is there a nicer way?  Any suggestions would be greatly appreciated.
Thanks!



Posted on the users mailing list.