Are spaces allowed after the `@` beginning a declaration in Objective-C?

declaration, objective-c

Solution

There is no formal specification for Objective-C (beyond The Objective-C Programming Language). There's definitely no BNF-style definition of the whitespace conventions. If it compiles, that's about the closest we have to "legal." This is true of many languages. Perl for instance is best defined as "those strings which the `perl` executable will not reject." (At least in my opinion....)

That said, the correct style is `@interface` without a space. See Defining a Class.

Problem

I am looking at Objective-C and I notice, for example, a class-interface declaration begins with `@interface`. Fine, no problema. The text, therefore, suggests no space is permitted between the `@` and `interface`. However, when I pass the following simple example to the GCC compiler in a `*.m` file: ``` @ interface A @ end ``` the compiler accepts the code without complaint. Can Anyone point Me in the direction of a reference which says explicitly whether or not `@ interface` is also considered acceptable by the Objective-C specification? I found nothing in Apple's 2008 and 2011 documents to say one way or the other besides the simple text alluded to earlier in the question. Thanks in advance. EDIT: It may be worth noting Emacs performs text coloring based on whether the identifier is a keyword or not; keywords are blue and non-keywords are yellow. The `@interface` colors blue and `@ interface` colors yellow. Similar behavior occurs in Vim.

Original source