This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: corrupt environment?


Keith Wright <kwright@tiac.net> writes:

> If Guile printed a message like:
> --  Syntax Error, internal definition may not follow expression
> then it would be up to you to read until you understood why.  Without
> the message, I don't think this can be called programmer error.
> It should be fixed.  But what does "fix" mean?
> 
> The quick fix would be to print an error message.  This might break
> some existing code, but either the fix would be simple, just move
> the defintions to the top, or the existing code contains an
> unmanifest bug.  So this message _should_ be printed, if not always
> at least when Guile operates in strict RnRS mode.

I strongly suspect, based on experience with SCM, that Guile does
not correctly interpret all internal defines.  Here are two that
have been incorporated into Jaffer's r4rstest.scm:

(letrec ((foo (lambda (arg)
		  (or arg (and (procedure? foo)
			       (foo 99))))))
    (define bar (foo #f))
    (foo #f))
 
==> 99

(letrec ((foo 77)
	 (bar #f)
	 (retfoo (lambda () foo)))
    (define baz (retfoo))
    (retfoo))

==> 77

Unfortunately, I don't have Guile built here at work, but will check
later.

SCM now actually rewrites internal DEFINEs to LETRECs.  There is an
immediate token that, when evaluated, means that the remaining forms
should be macroexpanded as an R5RS "body", and internal DEFINEs
converted.  The check for the immediate token costs very little: Each
form before the last in a body or BEGIN must already be checked for
immediateness, but the test seldom succeeds since such forms have no
effect.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]