Hi! I don’t know if this question has ever been answered before since it’s really hard to find this kind of answers on the devforum or even online, but I just wanted to know if more functions with the @ tag (like @native) existed:
Thanks!
As far as I’m aware, there are no others valid at this moment, but in the latest release notes Roblox announced introducing support for the @deprecated
attribute. I think that’s it, though. (last time I checked this attribute didnt work quite yet so it may not work straight away)
There are a couple.
@native -- For faster execution.
--!strict -- For strict type checking.
--!nonstrict -- For basic type checking.
--!optimize 0 -- For slower execution. [I think.]
--!optimize 1 -- For a bit faster execution than optimize 0.
--!optimize 2 -- Kind of same as @native but as a user below pointed out, it runs the code a bit differently and is better for performance.
And as @12345koip mentioned, @deprecated
.
But in the end, you won’t really use them a lot.
just asking, is there some kind of special setting you need to enable for those? is it a beta feature?
I tried these on my own functions and they gave me syntax errors. I also tried it on Lua as well as Roblox Luau, and i got syntax errors there too. Just curious, that’s all. (obviously apart from
@strict
which JIT compiles ur code)
I seem to have made a typo while writing it.
optimize 0, 1 and 2
all work if you type them like so: --!optimize 0,1 and 2
that is, for the whole script. They aren’t available for function declaration.
short answer: NOPE, you’re wrong
–!native exists, @native doesn’t
–!strict exists, @strict doesn’t
–! optimize 0-2 exists, @optimize never saw the day on roblox
and optimize 2 isn’t the same as native, it justs runs code differently which is worse for debugging but better for performances, while native directely compiles code into machine code.
Kind of late to point that out. Better luck next time I suppose.
I’ll edit my reply.
@native
exists for both the --!
syntax and as a function attribute
using it like this:
@native local function func(...)
end
means just that function will be JIT compiled
applying it as a flag:
--!native
means the whole script will be JIT compiled
yes mb im dumb, i even used it in the main thread lol
Maybe you should think before pointing out others’ mistakes. It would make you look better.
I’m a little late, but @checked
also exists! :D
I accidently discovered this with the Alt + F function filter thingy
So theres @native
, @checked
and soon @deprecated
:)
There is also
--!nocheck -- For no type checking at all
--!nolint -- To disable deprecation warnings and such
these are all of them (i think)
though you can’t use @deprecated currently