Re: Scheme bug in internal define

From: Brian Denheyer <briand_at_northwest.com>
Date: Sat, 8 Nov 1997 19:39:06 -0800 (PST)

Thomas Neumann writes:
> Keith Wright writes:
> > The following program exhibits a bug in both STk and Guile.
> > (Somebody ought to try it on SCM.)
> > One would expect it either to print "good" twice, or
> > to display an error message. In fact it prints "good"
> > and then "bad". MIT scheme prints "good" twice.
> > I have STk-3.1 and guile-core-971005.
> >
> > (define (bug)
> > (define good "good")
> > (define bad "bad")
> > (define (do-good) (display good)(newline))
> > (do-good)
> > (define ugly #f)
> > (do-good))
> > (bug)
>

scm prints good and then bad.

> I believe all (define ...) statements must appear first within
> a block and may not be intermixed with other code. If you do,
> the behaviour is undefined. I don't remember if this is defined
> in R4RS somewhere; it's briefly mentioned in SICP.
>
> -t
>
>
>From r4rs :

  Definitions are valid in some, but not all, contexts where expressions
   are allowed. They are valid only at the top level of a <program> and,
   in some implementations, at the beginning of a <body>.
  
Received on Sun Nov 09 1997 - 04:35:38 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST