From: Linus Torvalds <torvalds@linux-foundation.org>
To: Al Viro <viro@ftp.linux.org.uk>
Cc: linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] bloody mess with __attribute__() syntax
Date: Thu, 5 Jul 2007 11:56:15 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.0.98.0707051144560.9434@woody.linux-foundation.org> (raw)
In-Reply-To: <20070705180742.GP21478@ftp.linux.org.uk>
On Thu, 5 Jul 2007, Al Viro wrote:
>
> I.e. you get per-attribute rules (fsckloads of them) and no way to tell
> what do the attributes apply to unless you know the rules for given attribute.
It basically boils down to "__attribute__((x))" is basically a _single_
keyword.
There is no "__attribute__" on its own, or "x" on its own. The two do not
make sense separately.
And that's the _accurate_ way of seeing attribute. Seeing it as a "type
attribute" is actively wrong, and that kind of thinking just leads you
down the wrong path (not just with qualifiers, but with __attribute__ as
done by gcc itself, where it's used for more than type attributes).
> I just don't like having no relationship between the syntax and operations
> on types, that's all.
You seem to think that "__attribute__" has some meaning of its own.
Not true.
Gcc already has things like
__attribute__((extended))
which acts not on types or variables, but on expressions and statements.
And it does not *make*sense* to think of that as just another "attribute".
It is *not* about the same kind of attributes as the type attributes at
all! If you think it is, you're thinking about it wrong. It's a totally
different kind of thing.
So instead of thinking about "__attribute__" as having some stand-alone
semantic meaning (it does *not*), think of it the way I do: the
"__attribute__" part is just an escape sequence into an extended parsing
thing, and "__attribute__((extended))" is really just another way to give
a way to say the _extended_ thing, without having to make it a keyword,
with all that implies.
In other words, I think your "__qualifier__" idea is fundamentally wrong,
because it misses the real _point_ of "attribute()".
The real point of "__attribute__" is that it's mis-named. But that does
not mean that it should be named "__qualifier__", because that just
re-inforces the initial mistake. Instead, it probably _should_ have been
named "__extension__", or something like that (or maybe "__escape__" or
"__magic_keyword__").
That ends up explaining all the gcc semantics. Because "__attribute__" as
gcc uses it really isn't about attributes per se, it's about extensions to
C semantics, in a way that doesn't violate the C rules that much, and in a
way that doesn't introduce infinite numbers of special identifiers in the
same global name-space.
So yes, I'd be ok with renaming it, and I don't think "__attribute__" is a
wonderful name, but we named it for gcc compatibility, so we're kind of
stuck with the name. But that doesn't mean that we have to be stuck with
thinking about it as a "symbol node attribute", because it really isn't,
and has never been that, even in gcc.
Linus
prev parent reply other threads:[~2007-07-05 18:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-05 9:35 Al Viro
2007-07-05 12:03 ` Arnd Bergmann
[not found] ` <OFC2AA6078.1DF7BE7E-ON4225730F.0044BE34-4225730F.0046B6F1@de.ibm.com>
2007-07-05 16:27 ` Al Viro
2007-07-05 15:36 ` Josh Triplett
2007-07-05 16:43 ` Al Viro
2007-07-05 18:50 ` Josh Triplett
2007-07-05 19:13 ` Al Viro
2007-07-05 19:35 ` Josh Triplett
2007-07-05 20:08 ` Al Viro
2007-07-05 20:56 ` Linus Torvalds
2007-07-06 3:26 ` Al Viro
2007-07-05 21:09 ` Josh Triplett
2007-07-05 16:41 ` Linus Torvalds
2007-07-05 16:53 ` Al Viro
2007-07-05 17:02 ` Chris Lattner
2007-07-05 17:09 ` Al Viro
2007-07-05 17:26 ` Linus Torvalds
2007-07-05 18:07 ` Al Viro
2007-07-05 18:56 ` Linus Torvalds [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.0.98.0707051144560.9434@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®