09glich2
(09glich)
October 24, 2024, 12:30am
#1
So i accidentaly typed the @ symbol into my code. It also turned everything behind it into my operator color aka (if local not else) I have no idea what this keyword/ operator does and would really like to know.
I also have no idea if this is a bug.
Nothing, it means nothing. If you’re seeing red highlights, it’s likely because Roblox Studio is flagging it as an invalid Lua variable name.
It’s part of Luau’s new attribute system.
[IMG_20240621_113304]
If anyone is curious, attributes go before function declarations. So you’d use it like this:
@native
local function foo()
end
foo(@native function end)
It isn’t enabled yet but it’s the start of Luau’s attribute system.
(RFC for it)
# Attributes (for Functions)
**Status**: Implemented
## Summary
Add a syntax for attributes to function declarations in the style of `@name` that can be placed before their declarations to adjust the behavior of the compiler, analyzer, and runtime.
These attributes would be valid in both the normal syntax for declaring functions and the syntax for anonymous functions, with or without locally scoped names.
Due to attributes being tied to the language's behavior, this proposal does not allow for them to be implemented by users. A mechanism to do so would be either very complex or wildly unsafe and is thus not considered by this proposal.
## Motivation
It's desirable to have control over various parts of Luau. Consider three potential attributes:
- `@native`, to indicate that a function should be compiled using native codegen
- `@inline`, to indicate that a function should be inlined where called
- `@deprecated`, to indicate that a function should be marked as deprecated by the analyzer
This file has been truncated. show original
5 Likes
Dekkonot
(Dekkonot)
October 24, 2024, 3:38pm
#4
Adding on to this:
Currently there’s only one user-facing attribute (@native
). An RFC has been accepted for a second one (@deprecated
) though and it will probably get added soon™.