0

In this thread the meaning of the @ symbol is explained: What does the '@' symbol mean in Swift?

In the thread @ is said to identify an attribute. But there's another statement saying it's a "compiler directive". I've also learned that the Objective-C like Swift statement: @autoreleasepool {...} nowdays can be used without the @ symbol.

So this leaves me quite puzzled. What is the actual meaning of the @ symbol itself? It seems to me it can be used for more than attributes but I've found no document explaining the exact rules for how to use @. Mostly I find examples on how to use it as an attribute.

Or is it that the language has changed lately and nowdays, with Swift 4, @ is for attributes only?

EDIT: Since I had remarks I should not ask about Swift and Objective C in the same thread I've edited the text to focus on Swift.

Oortone
  • 175
  • 7
  • 1
    In Swift it is `autoreleasepool { ... }` – without the @ – for a long time now. – Martin R Apr 13 '18 at 08:00
  • OK, I see but it's used in Objective C and in that case I believe it's not correct to say it's an attribute. So the question remains what the actual meaning of the @ symbol itself is in these languages. – Oortone Apr 13 '18 at 08:02
  • But then you have to ask about Objective-C and not about Swift – that are two different languages. – Martin R Apr 13 '18 at 08:03
  • For Objective-C it is answered here: [What does the @ symbol represent in objective-c?](https://stackoverflow.com/questions/25749/what-does-the-symbol-represent-in-objective-c). – Martin R Apr 13 '18 at 08:06
  • I see a big similarity in the use between these languages (much like many operators) so my goal is to get an idea what the general meaning of the symbol is. That's why I specified both languages in my heading. @ is often translated to "at" but it doesn't seem to be how to understand the symbol in the case of Swift and Objective C. – Oortone Apr 13 '18 at 08:07
  • Martin R: Unfortunately I don't think the linked thread about objerctive c really answers my question. I tried to find an explanation in the language references for Swift and Objective C but failed. It's really hard to perform a search with just the @ symbol. – Oortone Apr 13 '18 at 08:13
  • 2
    First decide which language you are asking about (and tag the question accordingly). Swift and Objective-C are *different languages,* and asking for the meaning of a symbol in both makes the question too broad. – With respect to Objective-C: *"The @ character ... is used to introduce Objective-C language keywords in a way that won't conflict with the other languages' keywords. "* in the linked-to Q&A seems pretty clear to me. – Martin R Apr 13 '18 at 08:18
  • I've edited the text so now it's only Swift. The linked objective-c thread is explaining a lot but also suffer the problem that there are multiple explanations and the exact meaning of the symbol remains unclear. – Oortone Apr 13 '18 at 10:30

0 Answers0