[racket] syntax, differently

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Mon Aug 2 09:56:35 EDT 2010

On Aug 1, 2010, at 12:34 AM, Mathew Kurian wrote:

> 1.----When you click on a defined function name, it is necessary that all the same phrases are highlighted throughout the whole file.

I don't think that's really what you want.  Consider the following (bad) code example:

(define x 17)

(define (func1 x)
(define (func2 x)
(define (func3 x)
   (local [(define-struct x (x y))
               (define (x y) ...)]

If I click on "x", do you really think ALL the x's should be highlighted, considering that they're four different variables, a struct, a field, and a function?

DrRacket already provides a smarter version of this feature: if you hit "Check Syntax", and then mouse-over a defined variable or function name, it draws an arrow to where that variable or function name was defined.  If you mouse-over the definition of a variable or function name, it draws arrows to all the places where that variable or function name is used.

> 2.----One other feature that would be excellent is actually a popup list that comes up whenever typing the first word after every parentheses. Since this is usually a name of a function, it would be useful if drracket lists all functions that begin with the first letter typed after the parentheses. After the second letter is typed, the list narrows down the list to include the first two characters typed...and so on. For beginning programmers, I found it useful to use that feature since it easens what the students have to remember, while promoting a good programming syntax.

Actually, this "code completion" feature is more useful for fairly advanced programmers than for beginners; it's incorporated into many professional IDE's like Eclipse, but usually NOT into pedagogical IDE's like DrRacket and BlueJ (this same debate comes up on the BlueJ list all the time).  For beginning programmers, frankly, I think it encourages trial-and-error programming: if you mis-remember the first letter or two of the function you need, you're more likely to pick a plausible one from the pop-up list than to go figure out what function you REALLY need.

Besides, absolute beginning programmers don't have all that many functions to remember -- under 200 in my whole book, probably under 100 in HtDP.  (Many of those in _Picturing Programs_ are image-manipulation functions that you seldom use, or arithmetic functions that you already know but are listed for completeness.)

Stephen Bloch
sbloch at adelphi.edu

Posted on the users mailing list.