Skip to main content

Attributes

Under Construction

Attributes are a metaprogramming resource that allow the user to link generic functions to be executed above program members, allowing them to change the behavior of the program.


Attributes from the Std Library

The Abstract's Starndard Library offers the implementation of some usefefull attributes for generic use. These are all of them:

Access attributes

These attributes controlls the access of the reference of the member.

AttributeUsed inDescription
@publicany program memberAllows any other member to access the reference
@internalany program memberAllows only members of the same project to access the reference
@privateany program memberAllows only parent and sibling members to access the reference
@allowAcessTo(string)any program memberAllows the access of the member to a certain reference
@allowAcessTo([]string)any program memberAllows the access of the member to a certain collection of references
@denyAcessTo(string)any program memberDenies the access of the member to a certain reference
@denyAcessTo([]string)any program memberDenies the access of the member to a certain collection of references
@staticany program memberForces the member to be stored and accessed stactically
@defineGlobal(string)any program memberCreates a named reference for the member in the root of the program
@defineGlobal([]string)any program memberCreates a collection of named references for the member in the root of the program

OOP attributes

These attributes controlls the Object-Oriented behavior of structures.

AttributeUsed inDescription
@finalStructuresDenies acces of inheritance of other structures
@abstractStructuresMarks a structure as abstract
@interfaceStructuresMarks a structure as a interface
@externInterfaceStructuresMarks a structure that will be implemented by a extern source
@valueOnlyStructuresMarks a structure as never alllowed to be alone in the heap
@referenceOnlyStructuresMarks a structure as never allowed to be allocated in the stack
@virtualFunctions (with structure as parent)Allows a function to be override in a structure that inherits it parent
@overrideFunctions (with structure as parent)Overrides a reference to a function of the inherited parent

Function attributes

These attributes modifies how functions are handled by the compiler.

AttributeUsed inDescription
@inlineFunctionsForce a function to be implemented instead of invoked when called
@noInlineFunctionsForce a function to be not inlined during optimization
@comptimeFunctionsForce a function to be executed during compilation
@runtimeFunctionsForce a function to be executed only during runtime
@callConv(Std.Compilation.Abi)FunctionsDeclarate the convention used for the calling on binary targets that support different ABIs

Overloading attributes

Attributes that changes how references behaves when acessed or writed to.

AttributeUsed inDescription
@get(string)FunctionsCreates or modifies the nammed field in the parent function, using this function and it getter
@set(string)FunctionsCreates or modifies the nammed field in the parent function, using this function and it setter
@indexerGetFunctionsOverloads the indexer operator for the parent function, using this function and it getter
@indexerSetFunctionsOverloads the indexer operator for the parent function, using this function and it setter
@implicitConvertFunctionsRegisters a implicit conversion of the type in the first parameter of the function to the return type of the function
@explicitConvertFunctionsOverloads the as operator to convert the type in the first parameter of the function to the return type of the function
@overrideOperatorFunctionsOverloads the action of the specified operator
@defineAttribute(string)FunctionsRegister the function as a new attribute with the specified name

Creating your own attribute

TODO