Date: Wed, 17 Nov 2004 10:30:24 -0700
From: "E. Weddington" <address@hidden>
To: David Brown <address@hidden>
Subject: Re: [avr-gcc-list] generic queue library for AVR GCC?
Cc: avr-gcc-list <address@hidden>
David Brown wrote:
Personally, I'd like to see the addition of a "critical" function
attribute, like in mspgcc. It is clearly readable, avoids any
requirements for extra local variables, generates optimal code,
and generates any required "goto out" automatically. You can use
it on inlined functions to avoid function call overheads if you
want.
I think that's a *great* idea!
Wouldn't that require a change to the syntax of the c language? Not
that it's a bad idea but just don't expect to see it soon unless
someone else has already proposed it to whatever committee oversees
the language.
As an aside, Java has a construct that would help here; you can put a
"try" around code that might fail and have a "finally" block that
always gets executed:
try {
begin_critical();
if (something_fails())
return;
more_code();
}
finally {
end_critical();
}
So even though there's a "return" in the try block, the "finally"
block will still get executed before the "return".
(I've been a c programmer for years and have just recently dipped my
toes in the Java waters. Java does have some nice ideas.)