Skip to content

Instantly share code, notes, and snippets.

@greghendershott
Created February 15, 2020 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greghendershott/fdd6ba54571a07a475d2fa918a56a2c9 to your computer and use it in GitHub Desktop.
Save greghendershott/fdd6ba54571a07a475d2fa918a56a2c9 to your computer and use it in GitHub Desktop.
;; provide.rkt
#lang racket/base
(module outer racket/base
(module inner racket/base
(define (foo x) x)
(define (bar x) x)
(provide foo bar))
(require 'inner)
(require racket/contract)
(provide foo)
(provide (contract-out [bar (-> number? number?)])))
(require 'outer)
;; This reports source path "provide.rkt/outer/inner" and id "foo":
(identifier-binding #'foo)
;; '(#<module-path-index:(submod "." inner) (submod "." outer) #<path:provide.rkt>>
;; foo
;; #<module-path-index:(submod "." outer) #<path:provide.rkt>>
;; foo
;; 0
;; 0
;; 0)
;; This reports source path "provide.rkt/outer" and id "provide/contract-id.bar.1".
(identifier-binding #'bar)
;; '(#<module-path-index:(submod "." outer) #<path:provide.rkt>>
;; provide/contract-id-bar.1
;; #<module-path-index:(submod "." outer) #<path:provide.rkt>>
;; bar
;; 0
;; 0
;; 0)
;;
;; The wrong path is the bigger problem than the wrong id.
;;
;; It means Dr Racket "Open Defining File" is wrong.
;;
;; Also, if it at least it reported the correct path? Then Racket Mode could even
;; find the definition location within by using the reported _nominal_ id "bar".
;; It already has tactics to handle a simple rename+contract. But it can't handle
;; this sort of reprovide+rename+contract.
;;
;; I realize that in some sense, the answer isn't "wrong" because
;; something defined in module A is "not the same thing" as a
;; chaperone for it defined in module B. But, identifier-binding
;; already attempts to distinguish "nominal" and "source", so it seems
;; reasonable to think it might handle this. Can it? And/or does
;; racket/contract need to help it somehow?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment