Meaning of graphical question-mark on reference hover in DrRacket?

Viewed 75

In the DrRacket GUI, hovering the mouse over a symbol often produces a graphical line between the symbol and other uses of the symbol in the file or a line from the symbol to an import origin for that symbol. Sometimes (but not always), the graphical line is accompanied by a graphical question mark (not a text question mark) as in the illustration below (look very carefully at the bottom of the line; the question mark is in dark purple on a black background, so it's quite hard to see, but it /is/ there). What is the meaning of that question mark?

enter image description here

1 Answers

DrRacket draws a blue arrow (no question mark) between a binding (definition, local binding, import, etc) and a reference to that binding.

It draws a purple arrow with a question mark between a binding and a possible reference within a syntax template. The question mark is a reminder that

  • that occurrence of the identifier might not be used as a reference
  • even if it is, it might refer to another binding

Here's a silly example:

#lang racket

(define-syntax-rule (define-undivider fname divisor)
  (define (fname quotient remainder)
    (println (list 'quotient quotient 'remainder remainder))
    (+ (* divisor quotient) remainder)))

(define-undivider f 10)
(f 2 5)  ;;=> 25

Some of the uses of quotient and remainder aren't references at all, because they occur inside of a quote expression. Others are references, but they refer to the function's arguments rather than the Racket functions. DrRacket can't tell that just by looking at the macro definition (and it's harder than you might think), so it marks the apparent binding relationship as a "maybe".

Related