Why do all procedures have to be defined before the compiler sees them?

Posted by incrediman on Stack Overflow See other posts from Stack Overflow or by incrediman
Published on 2010-06-04T20:08:47Z Indexed on 2010/06/08 1:52 UTC
Read the original article Hit count: 241

Filed under:
|
|
|
|

For example, take a look at this code (from tspl4):

(define proc1
  (lambda (x y)
    (proc2 y x)))

If I run this as my program in scheme...

#!r6rs
(import (rnrs))

(define proc1
  (lambda (x y)
    (proc2 y x)))

I get this error:

expand: unbound identifier in module in: proc2

...This code works fine though:

#!r6rs
(import (rnrs))

(define proc2
  +)

(define proc1
  (lambda (x y)
    (proc2 y x)))

(display (proc1 2 3)) ;output: 5

© Stack Overflow or respective owner

Related posts about Scheme

Related posts about define