racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
447 stars 94 forks source link

#%app gets syncheck:add-jump-to-definition but #%datum does not #446

Closed greghendershott closed 3 years ago

greghendershott commented 3 years ago

Like #445 this is about the new annotations arising from commit 45fb5f5.

But that's already a long thread. And, this seems like a very specific question (that has nothing to do with points or intervals or API design -- whew! :smile:)


In a program like:

#lang racket/base
(define (foobar) 42)
(foobar)

(As presented by DrRacket, the difference is that "Open Defining File" is offered for #%app but not #%datum.)

Is this difference intentional and if so why?

rfindler commented 3 years ago

Looks like the #%app in that program is defined in racket code but the #%datum isn't. You also won't see a jump-to-definition for car in this program

#lang racket
car

Here's a little script that shows basically the information that's being used in this program if you want to play around more with other examples:

#lang racket/base

(define ns (make-base-namespace))
(define stx
  (parameterize ([current-namespace ns])
    (expand (read-syntax "x.rkt"
                         (open-input-string "(module m racket/base (+ 42))")))))
(let loop ([stx stx])
  (when (and (identifier? stx)
             (or (equal? (syntax-e stx) '#%datum)
                 (equal? (syntax-e stx) '#%app))
             (equal? (syntax-source stx) "x.rkt"))
    (printf ">> ~s\n  ~s\n" stx (identifier-binding stx)))
  (cond
    [(syntax? stx)
     (loop (syntax-e stx))
     (loop (syntax-property stx 'origin))]
    [(pair? stx)
     (loop (car stx))
     (loop (cdr stx))]))
jackfirth commented 3 years ago

Sounds like this is intentional and working correctly, so closing this. Feel free to reopen with more questions.