[racket] current-module-name-resolver and syntax/docprovide
After stumbling across the syntax/docprovide module in the
documentation, and trying to use it, I discovered this error:
#lang racket/base
(require syntax/docprovide)
(let ([orig-resolver (current-module-name-resolver)])
(parameterize ([current-module-name-resolver
(case-lambda
[(rmp ns) (orig-resolver (rmp ns))]
[(mp rmp stx load?) (orig-resolver mp rmp stx load?)])])
(lookup-documentation 'net/url 'get-pure-port)))
; ...c/docprovide.rkt:7:18: arity mismatch;
; the expected number of arguments does not match the given number
; given: 3
; arguments...:
; 'net/url
; #f
; #f
; Context:
; /Users/greg/src/scheme/misc/docprovide.rkt:1:1 [running body]
; /Users/greg/src/plt/racket/racket/collects/syntax/docprovide.rkt:254:0
lookup-documentation
>From a quick glance inside syntax/docprovide.rkt, it seems this is
where current-module-name-resolver is being called with 3 args,
instead of the documented 2 or 4:
(define (lookup-documentation path label)
(let ([mod ((current-module-name-resolver) path #f #f)])
(dynamic-require mod (void))
((dynamic-require-for-syntax
'syntax/private/doctable
'lookup-documentation)
mod
label)))
Actually the original/default current-module-name-resolver seems to
have no problem with this 3-arg variant. But my replacement didn't
expect it.
As I'm not 100% crisp on the module name resolver protocol, I'm not
sure where the correct fix is.
- Is there some 3-arg variant of c-m-n-r that needs to be documented?
- Should I "defensively" add a 3-arg variant, and chain to the
original? That would avoid an abend. But (say) I'm checking in the
2-arg case to do something special. If I get 3 args, I don't know if
it's supposed to be like the 2-arg or 4-arg case... much less which
args mean what.
- Should syntax/docprovide.rkt be changed to the 2 or 4 arg variant?
---
To back up a step: Is syntax/docprovide something that is intended to
be used these days? At a quick glance it seems like "only" a doc
string-ish facility, unconnected with the main Racket doc system. For
example even after hacking a fix to c-m-n-r, (lookup-documentation
'net/url 'get-pure-port) just returns #f. IIUC because net/url isn't
using provide-and-document to supply something. So this seems like an
alternative lightweight doc system, but it's not actually used; is
that correct?