Specifiers in Verse describe behavior related to semantics, and can add specifiers to identifiers and certain keywords. Specifier syntax uses angle brackets (<
and >
) with the keyword in between. For example, in IsPuzzleSolved()<decides><transacts>:void
, "decides" and "transacts" are specifiers.
Attributes in Verse describe behavior that is used outside of the Verse language (unlike specifiers, which describe Verse semantics). Attribute syntax uses the at sign (@
) followed by the keyword, for example @editable
.
The following sections describe all of the specifiers and attributes available in Verse and when you can use them.
Effect Specifiers
Effects in Verse indicate categories of behavior that a function can exhibit. You can add effect specifiers to:
After the
()
in a function definition:name()<specifier>:type = codeblock
.The
class
keyword:name := class<specifier>(){}
.
Specifier | Description | Example |
---|---|---|
no_rollback | This is the default effect when no exclusive effect is specified. The |
|
transacts | This effect indicates that any actions performed by the function can be rolled back. The |
|
computes | This effect requires that the function has no side effects, and is not guaranteed to complete. There’s an unchecked requirement that the function, when provided with the same arguments, produces the same result. Any function that doesn’t have the |
|
converges | This effect guarantees that not only is there no side effect from the execution of the related function, but that the function completes (does not infinitely recurse). This effect can only appear in functions that have the native specifier, but this isn’t checked by the compiler. Code that provides default values for class fields or values for global variables is required to have this effect. |
|
decides | This effect indicates that the function can fail and that calling this function is a failable expression. Because a |
|
suspends | This effect indicates that the function is async. Creates an async context for the body of the function. Mutually exclusive with the |
|
reads | This effect indicates that the same inputs to the function may not always produce the same output. The behavior depends on factors external to the specified inputs, such as memory or the containing package version. |
|
writes | This effect indicates that the function may change values in memory |
|
allocates | This effect indicates that the function may instantiate an object in memory. Allocating |
|
In all cases, calling a function that has a specific effect will require the caller to have that effect as well.
Access Specifiers
Access specifiers define what can interact with a member and how. You can apply access specifiers to the following:
The identifier for a member:
name<specifier> : type = value
The keyword
var
for a member:var<specifier> name : type = value
You can have an access specifier on both the identifier and the var
keyword for a variable, to differentiate between who has access to read and write the variable. For example, the following variable MyInteger
has the public specifier on the identifier so anyone can read the value, but the var
keyword has the protected specifier so only the current class and subtypes can write to the variable.
var<protected> MyInteger<public>:int = 2
Specifier | Description | Usage | Example |
---|---|---|---|
public | The identifier is universally accessible. | You can use this specifier on:
| Verse
|
protected | The identifier can only be accessed by the current class and any subtypes. | You can use this specifier on:
| Verse
|
private | The identifier can only be accessed in the current, immediately enclosing, scope (be it a module, class, struct, etc.). | You can use this specifier on:
| Verse
|
internal | The identifier can only be accessed in the current immediately enclosing, module. This is the default access level. | You can use this specifier on:
| Verse
|
scoped | The identifier can only be accessed in the current scope and any enclosing scopes. Any assets you expose to Verse that appear in the Assets.digest.Verse file will have the | You can use this specifier on:
| Verse
|
Class Specifiers
Class specifiers define certain characteristics of classes or their members, such as whether you can create a subclass of a class.
Specifier | Description | Example |
---|---|---|
abstract | When a class or a class method has the | Verse
|
castable | Indicates that this type is dynamically castable. The The | Verse
|
concrete | When a class has the | Verse
|
unique | A unique class in Verse is assigned a unique identity for each instance. This means that, even if two instances of the same unique class have the same field values, they are not equal since they are distinct instances. This allows instances of unique classes to be compared for equality by comparing their identities. Classes without the unique specifier don't have any such identity, and so can only be compared for equality based on the values of their fields. This means that unique classes can be compared with the = and <> operators, and are subtypes of the comparable type. | Verse
|
final | You can only use the
| Verse
|
final_super | The This is necessary in Scene Graph for immediate subtypes of | Verse
|
Persistence Specifier
When a custom type, such as a class, has the <persistable>
specifier, it means that you can use it in your module-scoped weak_map variables and have its values persist across game sessions. For more details on persistence in Verse, check out Using Persistable Data in Verse.
You can use the persistable specifier with the following types. Follow the links for more details.
Open and Closed Specifiers
Currently usable only with enums. The <open>
and <closed>
specifiers determine how you can change the definition of the enum once your island is published.
You can use the open and closed specifiers with the following types. Follow the links for more details.
Specifier | Description | Example |
---|---|---|
Open | A specifier that currently applies to enums only. You can add or reorder enum values in an open enum, or change it to a <closed> enum. Open enums are best used when you expect the number of values in your enum may increase in the future. For example, an enum of weapon types. | Verse
|
Closed | A specifier that currently applies to enums only. Enums are closed by default. Closed enums are best used for cases where your values are expected to stay the same, like days of the week. | Verse
|
Implementation Specifiers
It's not possible to use implementation specifiers when writing code, but you will see them when looking at the UEFN APIs.
Specifier | Description | Example |
---|---|---|
native | Indicates that the definition details of the element are implemented in C++. Verse definitions with the
| Verse
|
native_callable | Indicates that an instance method is both native (implemented in C++) and may be called by other C++ code. You can see this specifier used on an instance method. This specifier doesn’t propagate to subclasses and so you don’t need to add it to a definition when overriding a method that has this specifier | Verse
|
Attributes
Attributes in Verse describe behavior that is used outside of the Verse language (unlike specifiers, which describe Verse semantics). Attributes can be added on the line of code before definitions.
Attribute syntax uses the at sign (@
) followed by the keyword.
Attribute | Description | Example |
---|---|---|
editable | Indicates this field is an exposed property that can be changed directly from UEFN so you don't need to modify the Verse code to change its value. For more details, see Customize Device Properties. | Verse
|
editable_text_box | An editable string that displays as a text box in the editor. Editable text boxes currently do not support tooltips or categories. For more details, see Customize Device Properties. | Verse
|
editable_slider | An editable slider that uses the float type. You can drag the slider in the editor to increase or decrease the value. For more details, see Customize Device Properties. | Verse
|
editable_number | An editable number with minimum and maximum. For more details, see Customize Device Properties. | Verse
|
editable_vector_slider | An editable vector slider. You can drag to change the values of each of the vector components. For more details, see Customize Device Properties. | Verse
|
editable_vector_number | An editable vector number, which can be a vector2, vector2i, or vector3. For more details, see Customize Device Properties. | Verse
|
editable_container | An editable container of values. Currently, this only supports arrays. For more details, see Customize Device Properties. | Verse
|