Subject: compiler tweak offered
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-toolchain
Date: 08/24/2002 22:57:54
I have succeeded in implementing a compiler tweak I've been
contemplating on and off for a while.  This note is to offer to feed it
back to the community if there is any interest.

It provides named control structure for loops and switches, allowing
you to do stuff like

	for "outer" (x=list; x; x=x->link) {
		while (...) {
			if (...) continue "outer";

Of course, it's nothing you can't do with gotos, but that's true of all
C's loops.  It does change the interpretation of certain very unusual
programs, those which involve do-loops whose body is a
non-brace-bracketed statement that happens to begin with a string
literal, such as

	do "string"[expression]; while (...);

This is legal (if pointless) C, but my patches turn it into a syntax
error.  for, while, and switch statements are not affected because of
the parens around the controlling code.  It doesn't matter to me, and
I've been unable to think of even a contrived example of code beginning
with a string literal where the string literal can't be trivially
removed.  (And of course, since any code beginning with a string
literal must be an expression statement, you can always just throw
parens - or braces! - around it.)

It was surprisingly easy to do, though I'm not 100% sure I don't have a
slight memory leak.  If anyone is interested, drop me a line.  (If
anyone wants to figure out where the gcc folks are these days and
either feed it back to them or tell me whom to write to to make a
similar offer to them, that's fine with me too.)

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B