Comment 8 for bug 456473

Revision history for this message
Derick Eddington (derick-eddington) wrote : Re: [Bug 456473] Re: latest fix for 'begin' causes error

On Wed, 2009-10-21 at 18:43 +0000, leppie wrote:
> $ ikarus --r6rs-script srfi/tests/multi-dimensional-arrays.sps
> Unhandled exception:
> Condition components:
> 1. &who: begin
> 2. &message: "invalid syntax"
> 3. &syntax:
> form: (begin)
> subform: #f
> 4. &source-position:
> file-name: "srfi/tests/multi-dimensional-arrays.sps"
> character: 676
> 5. &trace: #<syntax (begin) [char 676 of srfi/tests/multi-dimensional-arrays.sps]>
> 6. &trace: #<syntax (past)>
>
> Not sure if it is Derrick's include code causing that, but it used to
> work. All the other SRFI use cases and tests works though.

On Wed, 2009-10-21 at 19:42 +0000, Abdulaziz Ghuloum wrote:
> I don't know why that code overrides the definition of past, and
> commenting out the binding of past in the let-syntax makes it pass all
> tests. Forwarding to Derick.

srfi/tests/multi-dimensional-arrays.sps uses its let-syntax to convert
the included code to use (srfi :78 lightweight-testing). That is done
instead of modifying the included file, so that the file remains
identical to the file released by the author, so that diffing or
patching it with updates from the author does not involve
not-originally-there content.

The purpose of the let-syntax binding of past is to make the included
uses of past disappear, because they are not relevant when the included
code is converted. The use of past is a hack so that, if a test fails
and calls error, using a debugger you can inspect the value returned by
(past) to know what "stones" the program went past to know what test
failed (bizarre, I know). The let-syntax-bound past transforms the uses
to (begin) to make them disappear.

The new issue is the empty (begin) forms. I think they are valid,
because top-level programs can have definitions and expressions
intermixed and so empty (begin) forms intermixed with expressions are
valid because they are valid definition forms. The following program
which does that works with Ikarus revision 1865 (and works with the
other R6RS systems):

$ cat top-level-begin.sps
#!r6rs
(import (rnrs))
(begin)
(define a 1)
(begin)
(define b 2)
(begin)
(display "one\n")
(begin)
(display "two\n")
(begin)
(display "three\n")
$ ikarus --r6rs-script top-level-begin.sps
one
two
three
$

So, if that program works, then so should the intermixed empty (begin)
forms in the expansion of srfi/tests/multi-dimensional-arrays.sps.