This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: compiler tweak offered


der Mouse wrote:
> 
> [replying to rth@redhat.com]

> >       for (elt=root; elt; elt=elt->link)
{
> >               if (...) goto continue_outer;
> >         continue_outer:;
}
> 
> Yes, except for three things: (1) it requires someone attempting to
> understand the control flow to check the whole rest of the function to
> see if that label is used anywhere else; (2) it can't be done twice in
> the same function (you have to pick different label names, whereas loop
> names can be reused freely); and (3) when you as a maintainer see the
> goto, you have to check that it really is doing what it looks as though
> it's doing.
I agree with Richard, this extension is syntactic sugar which
does not give you sufficient leverage to justify its existance.
In rth's example he named the label 'continue_outer'. Therefore there's
a resonable expectation that that's what it does. If it doesn't
either (a) its a bug, or (b) the programmer is deliberately obfustcating
things. That you can't do it twice with the same name is a good thing.
Your extension, I presume allows me to write
	for "outer" (...) {
		... lots of code
		continue outer;
		... lots of code
	}

	for "outer" (...) {
		... lots of code
		continue outer; // which outer? how do I find it?
	}

I'd use labels and call the first one 'search_outer', and the second
'process_outer', if that's what the loops were doing.

Your labels appear to have a funny scope, which no other name does.
I presume you can't write
	for "label () { for "label" () {} }
(because to do so would kind of defeat the purpose)
a new scoping level doesn't allow you to create a new label with the
same name (unlike varibles for instance, but like labels). However, you
can write the above example, with the same name, so they do have a
restricted scope (like variables, but unlike labels).

You've obviously got to grips with the innards of gcc, and I hate
to dishearten you about contributing. If you want to do so, fix bugs or
look at the projects page for things. If you need motivation, fix the bugs
that you trip over.

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org


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