Opening braces in all I6 inclusions require following whitespace in Ver 10

Since I just wasted an hour of my life debugging a simple routine before twigging this, I thought I’d put it up here for posterity in the hope of saving others from similar perdition.

The documentation warns that for inline code that might expect to receive an I7 parameter in the form {n}, e.g.

To simple-print (n - a number): (- print {n}; -).

one must avoid whitespace after the opening brace to make clear that this is an I7 parameter substitution, not I6 code bracing (such as might be used after an I6 if statement).

However, it never occurred to me until today that the same consideration might be true of code within included I6 routines.

However, after

Include (-
[ TestBraces;
	if (1==1) {print 1;}
	if (2==2) { print 2;}
];
-).

we get

[ TestBraces;
    if ((1 == 1)) {
        if ((2 == 2)) {
            print 2;
        }
    }
];

as compiled output in auto.inf

Essentially I believe {print 1;} has been parsed by the compiler as a spurious I7 parameter substitution, and there being no such I7 parameter as print 1; it has just vanished in a puff of smoke.

Conversely, { print 2;} is parsed correctly.

Overall, the outcome is identical to

Include (-
[ TestBraces;
	if (1==1)
	if (2==2) { print 2;}
];
-).

(the outer paired braces in the compiled output are inserted by the compiler, as they are after every unbraced if statement in I6 inclusions- they are not residual or derived from {print 1;})

4 Likes