Some types and methods can be annotated with attributes. The attribute list is fixed, but eventually (maybe) there will be user-defined attributes.
Tells the compiler how to link a C library. This is explained in the lib section.
The @[ThreadLocal]
attribute can be applied to global variables and class variables. It makes them be thread local.
# One for each thread
@[ThreadLocal]
$values = [] of Int32
Allows marking a C struct as packed, which makes the alignment of the struct to be one byte, and that there is no padding between the elements. In non-packed structs, padding between field types is inserted according to the target system.
Gives a hint to the compiler to always inline a method:
@[AlwaysInline]
def foo
1
end
Tells the compiler to never inline a method call. This has no effect if the method yields.
@[NoInline]
def foo
1
end
Marks a method or lib fun as returning twice. The C setjmp
is an example of such a function.
Marks a method or lib fun as potentially raising an exception. This is explained in the callbacks section.
Indicates the call convention of a lib fun. For example:
lib LibFoo
@[CallConvention("X86_StdCall")]
fun foo : Int32
end
The list of valid call conventions is:
They are explained here.
Marks an enum as a "flags enum", which changes the behaviour of some of its methods, like to_s
.