GithubHelp home page GithubHelp logo

Comments (3)

greghendershott avatar greghendershott commented on June 12, 2024

I'd tested on procedures defined with define/contract and plain provide, which worked.

But I confirm what you're reporting, with an example using (provide/contract) or (provide (contract-out ..)).

The problem is that we definitely do want source-id in the case of a (provide (rename-out ...)). In that case, nominal-source-id is the renamed/provided thing, and source-id is how it was actually defined.

In other words, identifier-binding seems to behave "backwards" for contract-out vs. rename-out. :(

Even worse, there's the case of (provide (contract-out [rename -FOO foo (-> any)])) -- that is, both rename and contract. In that case source-id is something like 'provide/contract-id-foo.13, nominal-source-id is foo, and neither of those is the -FOO identifier used at the definition site.

Maybe I need to try finding all 3 of the possibilities -- the value from the Emacs buffer, source-id, and nominal-source-id -- in the source file, until one succeeds (or none do)?? That seems a bit kludgy, but maybe it's the only way to accomplish this. I think I'll post to the Racket mailing list to ask.


;;; provide.rkt
#lang racket

(define (f)
  0)
(provide f)

(define (-r)
  0)
(provide (rename-out [-r r]))

(define/contract (dc)
  (-> any)
  0)
(provide dc)

(define (pc)
  0)
(provide (contract-out [pc (-> any)]))

(define (-pcr)
  0)
(provide (contract-out [rename -pcr pcr (-> any)]))

;;; some-other-file.rkt
#lang racket
(require "provide.rkt")
(pretty-print
 (for/list ([sym '(f r dc pc pcr)])
   (match (identifier-binding (namespace-symbol->identifier sym))
     [(list source-mpi source-id
            nominal-source-mpi nominal-source-id
            source-phase import-phase nominal-export-phase)
      (list sym "source" source-id "nominal" nominal-source-id)])))

;; ==>
;; '((f "source" f "nominal" f)
;;   (r "source" -r "nominal" r)
;;   (dc "source" dc "nominal" dc)
;;   (pc "source" provide/contract-id-pc.9 "nominal" pc)
;;   (pcr "source" provide/contract-id-pcr.13 "nominal" pcr))

from racket-mode.

greghendershott avatar greghendershott commented on June 12, 2024

Note: Although commit 0115d51 fixes the specific issue originally reported, it doesn't handle the contract-out plus rename permutation I discussed above. Handling that, if possible at all, will require another approach.

from racket-mode.

greghendershott avatar greghendershott commented on June 12, 2024

Commit 1af7969 adds handing the renaming/contracting provides.

from racket-mode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.