[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Scm-discuss] nested define question

From: Tom Kwong
Subject: [Scm-discuss] nested define question
Date: Tue, 25 Sep 2012 23:16:02 -0300


Can someone please explain why the following nested define structure does not work?
Thanks in advanced.

SCM version 5e7, Copyright (C) 1990-2006 Free Software Foundation.

> (define (abc)
  (define (a) 1)
  (define b (a))
  (print b))
;ERROR: unbound variable:  a
; in _expression_: (a)
; in scope:
;   (b a . address@hidden)
;   ()

Compare with the letrec version:

> (define (abc)
  (letrec ((a (lambda () 1))
       (b (a)))
    (print b)))
> 1

reply via email to

[Prev in Thread] Current Thread [Next in Thread]