<const> and <close> attributes.
Feature Flag
Version-Specific Nodes
Attribute
An attribute on a local variable declaration. Location:full_moon::ast::lua54::Attribute
Methods
new(name: TokenReference) -> Self- Creates a new Attribute with the given namename(&self) -> &TokenReference- The attribute name (e.g.,constorclose)brackets(&self) -> &ContainedSpan- The angle brackets (<and>) surrounding the attributewith_name(self, name: TokenReference) -> Self- Returns a new Attribute with the given namewith_brackets(self, brackets: ContainedSpan) -> Self- Returns a new Attribute with the given brackets
Attribute Types
<const> Attribute
Marks a variable as constant (cannot be reassigned).
<close> Attribute
Marks a variable as to-be-closed. When the variable goes out of scope, its __close metamethod is called.
Examples
Constant Variables
To-Be-Closed Variables
Multiple Attributes
Usage
Inherited Features
Sincelua54 enables lua53 and lua52, you also get:
- Bitwise operators (see Lua 5.3)
- Goto statements and labels (see Lua 5.2)
- All Lua 5.2 and 5.3 syntax features
Notes
- Attributes are only valid on local variable declarations
- A variable can only have one attribute
- The attribute must immediately follow the variable name
- Constant variables must be initialized when declared
- To-be-closed variables require a value with a
__closemetamethod (ornil/false)