Many of the code constructs within a Sling program can be followed by optional modifiers that give the compiler more information about the construct in question. Particularly, modifiers are frequently attached to variable declarations, function/method declarations and entity declarations (classes and interfaces).
Modifiers are generally grouped into two categories: Standard (built-in) modifiers and custom modifiers. As the names suggest, the standard modifiers are built in to the compiler and cannot be modified or extended by the programmer, whereas a Sling programmer can freely attach any custom modifier to code constructs of their choosing.
Some samples of standard modifiers would include public, private, abstract, const, etc. The modifiers could be used eg. as follows (note the use of "private" and "const" modifiers below):
func myFunction private
{
var n const = 10
}
A custom modifier is identified by a preceding hash character, and consequently, a custom modifier appears as a hashtag. The following attaches a custom modifier to the variable declaration:
func myFunction private
{
var n const #myCustomModifier = 10
}
Custom modifiers can be attached to any code construct that can otherwise have modifiers, notably variable declarations, functions and entities. In addition, string literals can also have a custom modifier attached to them, eg. the following (the custom modifier #customText is attached to the string "this is a string literal"):
func myFunction
{
callOtherFunction("this is a string literal" #customText)
}