Skip to main content

identifier

Identifiers in Soul are names used to identify variables, functions, classes, and other program elements. They are fundamental building blocks that allow you to reference and manipulate data throughout your program.

Basic Identifiers

Simple variable names:

Identifier Rules

Valid identifier naming rules:

Naming Conventions

Recommended naming patterns:

Variable Identifiers

Variables with different scopes:

Function Identifiers

Function names as identifiers:

Class and Object Identifiers

Class names and object properties:

Property Identifiers

Object property access:

Array and Map Identifiers

Collection variable names:

Loop Variable Identifiers

Identifiers in loops:

Function Parameter Identifiers

Parameter names in functions:

Private-like Identifiers

Convention for private variables:

Constant-like Identifiers

Convention for constants:

Namespace Identifiers

Module and namespace identifiers:

Special Identifiers

Reserved and special identifiers:

Dynamic Identifiers

Identifiers created dynamically:

Identifier Validation

Checking identifier validity:

Best Practices

  1. Use descriptive names: userAccountBalance instead of bal
  2. Be consistent: Choose one naming convention and stick to it
  3. Avoid abbreviations: firstName instead of fName
  4. Use meaningful prefixes: is for booleans, get for getters
  5. Avoid reserved words: Don’t use language keywords as identifiers
Identifiers are crucial for creating readable, maintainable Soul code. Choose names that clearly express the purpose and content of your variables, functions, and other program elements.