[racket] Why "reference to an identifier before its definition" in this program?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Dec 25 18:08:52 EST 2011

Yes, -> acts basically like a function. With the current
implementation, you need to delay things if you want that behavior,
eg:

(define/contract (x input)
  (-> (lambda (x) (y x)) any)
  3)

Robby

On Sun, Dec 25, 2011 at 4:52 PM, Eric Hanchrow <eric.hanchrow at gmail.com> wrote:
> This is racket v5.2.
>
> #lang racket
>
> (define/contract (x input)
>  (y . -> . any/c)
>  3)
>
> ;; (define (x input)
> ;;   (y)
> ;;   3)
>
> (define (y)
>  #t)
>
> When I run this, I get
>
> racket ./hmm.rkt
> reference to an identifier before its definition: y in module: ...
>
> However, if I comment out the first definition of x, and uncomment the
> second, I don't get an error.
>
> What is the difference?  Is this a bug?  It'd be nice if I could use a
> defined-later-in-the-file function in my contract; otherwise I have to
> carefully order the functions in the file, which makes it harder to
> read the file.
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.