Basic Predefined Commands: Assign and Aliases
Among SOP Lang Pipeline's simplest yet most fundamental commands are assign and alias. The assign command is engineered to accept multiple parameters, whether existing variables or literal text segments, and concatenate them into a single, more comprehensive string. This capability is crucial for dynamically constructing detailed and context-rich prompts. For conciseness and enhanced readability, assign can also be expressed using the special operator :=.
Example 1: Basic Prompt Construction Using assign
In this example, several variables are declared and combined with literal text to form a complete prompt segment.
@modelRole := "You are a helpful and expert AI research assistant."
@userQueryTopic := "the impact of quantum computing on cryptography"
assign @promptIntroduction $modelRole " The user is asking about " $userQueryTopic ". Provide a concise overview."
# @promptIntroduction:
# "You are a helpful and expert AI research assistant. The user is asking about the impact of quantum computing on cryptography. Provide a concise overview."
Example 2: Using := for Compact Concatenation
This example demonstrates the := operator in a compact form and combines multiple pieces of contextual information in one assignment.
@userName := "Dr. Evelyn Reed"
@specificInstruction := "focus on potential vulnerabilities in current encryption standards"
@outputLength := "a summary of no more than 200 words"
@detailedPrompt := "The request comes from " $userName ". Specifically, " $specificInstruction ". Deliver " $outputLength "."
# @detailedPrompt:
# "The request comes from Dr. Evelyn Reed. Specifically, focus on potential vulnerabilities in current encryption standards. Deliver a summary of no more than 200 words."
Example 3: Simple String Concatenation
This illustrates straightforward concatenation for labels and filenames, a common pattern when assembling textual artefacts in SOP documents.
@projectID := "QuantumLeap_2025"
@status := "InProgress"
@fileExtension := ".txt"
@statusLabel := "Project: " $projectID " - Status: " $status
@documentFileName := $projectID "_" $status $fileExtension
# @statusLabel => "Project: QuantumLeap_2025 - Status: InProgress"
# @documentFileName => "QuantumLeap_2025_InProgress.txt"
Example 4: alias Across Documents
The preceding examples abstracted the fact that SOP Lang Pipeline commands reside within documents. For scenarios requiring access to a variable defined in a different document, the special alias command establishes an equivalence, effectively creating a local alias that points to a variable declared elsewhere.
This mechanism is crucial for modularity, reusability, and better organisation of complex projects. It resembles symbol resolution across modules more than a typical import statement in imperative languages.
# Document: definitions
@greetingPart := "Hello"
# Document: app
alias @localGreeting "definitions" greetingPart
@message := $localGreeting ", World!"
# @message => "Hello, World!"
This minimalist pattern demonstrates the core function of alias: a variable is defined in one document, another document creates a local name that refers to it, and that local alias can be used as if it were defined directly in the local command context.
Additional Dependencies with await
In SOP Lang Pipeline, the reactive re-evaluation of a variable is typically triggered by changes in the input variables directly used in the command that defines it. However, there are scenarios where a variable's update should also be conditioned by changes in other variables, even if those variables do not directly contribute to its computed value. The await keyword addresses this need by allowing explicit declaration of such additional dependencies.
When await is used, the command will re-execute if any direct input variable changes or if any variable listed after the await clause changes. This extends the dependency list of the defined variable and enables explicit synchronisation points in a reactive script.
Syntax pattern: @outputVariable command expression await $dependency1 $dependency2 ....
Typical use cases are explicit trigger variables, synchronisation boundaries, and indirect reactive links where update responsibility should not be encoded directly as a value input.
@var1 := v1
@var2 := v2
@var3 := $var1 await $var2
# @var3 takes its value from $var1.
# @var3 re-evaluates when either $var1 or $var2 changes.
This mechanism is particularly useful when computations involve side effects, or when a value needs to be refreshed because an environment variable or trigger variable changed.