I understand what @mjbshaw is saying about offsetof
looking cleaner as a macro, but I disagree for two reasons:
- Magic macros are keywords, they just don’t look like keywords.
- It will be very confusing if we reimplement it as a macro.
The former problem makes it difficult for others to implement new compilers (I’m assuming that rust will become popular enough that others will want to). You have to know that some keywords look like macros, while others don’t. With a clean macro syntax it’s a bit easier.
The latter problem is confusing for end users; up until RFC 2421, the documentation told everyone that offsetof
(along with a few other keywords) might some day become keywords. If I turn on syntax highlighting for rust, they are colored as keywords. So I’m used to thinking of offsetof
as a keyword. Now it isn’t, so I have to mentally remember that I could use it as an identifier. If we adopt a macro of offsetof!
that is actually a magic macro (keyword) and not a real macro, I now have to remember that pre-2015, offsetof
was reserved, for sometime in 2015-2019 (dates? When did this change make it to stable?), offsetof
wasn’t reserved, but there also wasn’t an official offsetof!
macro, but after edition 20XX, there is an offsetof!
, which looks like a macro, but is actually a keyword. That has a code smell to it that is difficult for me to describe.
Honestly, if it was up to me, I’d retract RFC 2421 immediately, and re-reserve all those words. Even if they are never used by rust, it will cut down on the confusion. If someone really needs to use a keyword (or reserved word) as an identifier, they can always use raw identifiers instead.