<br>[DrRacket version 5.3, Language: racket]<br><br>A colleague stumped me and I confirmed the behavior...<br><br>* range is a provided procedure, but suppose we redefine it ourselves, in curried form:<br><div>(define (range lo)</div>
<div> (lambda (hi) (if (> lo hi) null (cons lo ((range (+ 1 lo)) hi)))))<br><br>or<br><br><div>(define ((range lo) hi)<br></div><div> (if (> lo hi) null (cons lo ((range (+ 1 lo)) hi))))</div><br>If you do this in the definitions window with #lang racket, no problem. If you do it in the interactions window, then the recursive call will instead be bound to the provided procedure, leading to an arity error.<br>
<br>Indeed, this has nothing to do with currying. If I instead define a non-curried function:<br><br>(define (range lo hi)<br> (print "hi")<br> (if (> lo hi) null (cons lo (range (+ 1 lo) hi))))<br><br>
in the definitions window, then running (range 3 7) in the interactions window will print "hi" 6 times. <br><br>But if I define this non-curried function in the interactions window, it prints "hi" only once -- the recursive call again binding to the built-in procedure.<br>
<br>I apologize if this is a known "feature" or a known "bug" -- I do scan the release notes briefly when new versions come out, but don't remember anything about this. Any pointers? Thanks!<br><br>
--Dan<br><br></div>