[racket] module-path-index and self-paths
I can't speak to why module-path-index-resolve doesn't work, but as a
workaround you might try using resolve-module-path-index from the
syntax/modresolve library (yes, just shuffle the verb to the front). It
takes a path to use as the self module, so it seems like it should avoid
the problem you're seeing.
Ryan
On 05/10/2011 10:26 PM, Danny Yoo wrote:
> I'm trying to trace down a bug in my code down to a user of
> module-path-index-resolve. I'm somehow getting a hold of a
> module-path-index with the following structure:
>
> (module-path-index-join "private/base.rkt"
> (module-path-index-join #f #f))
>
>
> When given this, module-path-index-resolve errors out and says:
>
> module-path-index-resolve: "self" index has no resolution:
> #<module-path-index>
>
>
> I'm trying to figure out if I'm misusing module-path-index-resolve. I
> am getting this particular module path index by zo-parsing
> collects/racket/base.rkt and looking into its phase-0 requires.
>
> Here is code to demonstrate where the value is coming from:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> #lang racket
> (require racket/match
> compiler/zo-parse)
>
> (define (run-zo-parse path)
> (parameterize ([current-namespace (make-base-namespace)]
> [read-accept-reader #t]
> [current-directory
> (let-values ([(base file is-dir)
> (split-path path)])
> base)])
> (let ([bc (compile (read (open-input-file path)))]
> [op (open-output-bytes)])
> (write bc op)
> (zo-parse (open-input-bytes (get-output-bytes op))))))
>
>
> ;; Splits up a module path index into its components.
> (define (explode-module-path-index mpi)
> (let-values ([(x y) (module-path-index-split mpi)])
> (cond
> [(module-path-index? y)
> (cons x (explode-module-path-index y))]
> [else
> (list x y)])))
>
>
> (match (run-zo-parse (build-path (find-system-path 'collects-dir)
> "racket"
> "base.rkt"))
> [(struct compilation-top (_
> _
> (struct mod (_ _ _ _ _ requires _ _ _ _ _ _ _))))
> (for ([phase-and-paths requires])
> (when (equal? (car phase-and-paths) 0)
> (displayln (map explode-module-path-index (cdr phase-and-paths)))))])
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
> The second element in the list value that displays:
>
> ((racket/private/pre-base #f) (private/base.rkt #f #f))
>
> is the module-path-index that I don't quite know how to resolve into a
> nice resolved-module-path.
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users