# Syntax

Solstice's syntax is similar to that of C-inspired languages, and should be familiar to anyone who has programmed in a language like C, C++, Java, Rust, JavaScript/Typescript, Kotlin, etc, etc.

## Expressions

An expression in Solstice is a combination of operators and values (whether literal or stored in a variable).&#x20;

### Expression Types

"Precedence" is a number which dictates the order of execution. The higher the precedence, the sooner an expression will be evaluated.

#### Binary Mathematical

* `+`: Adds two numbers on either side, or concatenates two strings
  * Accepts:
    * Two integers either side
    * Two doubles either side
    * Two strings either side
    * An integer and a double on either side (order not significant)
  * Returns:
    * The sum of both values as an integer if both values are integers
    * The sum of both values as a double if one value is a double and the other is an int, or both values are doubles
    * The concatenated string when both values are strings
  * Precedence: 5
* `-`: Subtracts two numbers on either side
  * Accepts:
    * Two integers either side
    * Two doubles either side
    * An integer and a double on either side (order not significant)
  * Returns:
    * The difference of both values as an integer if both values are integers
    * The difference of both values as a double if one value is a double and the other is an int, or both values are doubles
  * Precedence: 5
* `*`: Multiplies two numbers on either side
  * Accepts:
    * Two integers either side
    * Two doubles either side
    * An integer and a double on either side (order not significant)
  * Returns:
    * The product of both values as an integer if both values are integers
    * The product of both values as a double if one value is a double and the other is an int, or both values are doubles
  * Precedence: 6
* `/`: Divides two numbers on either side
  * Accepts:
    * Two integers either side
      * Two doubles either side
        * An integer and a double on either side (order not significant)
  * Returns:
    * The quotient of both values as an integer if both values are integers
    * The quotient of both values as a double if one value is a double and the other is an int, or both values are doubles
  * Precedence: 6

#### Binary Comparative

* `==`: Checks two values to determine if they are equal
  * Accepts:
    * Any two values either side which are of the same type
    * An integer and a double on either side (order not significant)
  * Returns:
    * `true` if both provided values are exactly the same.&#x20;
    * `false` otherwise.
  * Precedence: 2
* `!=`: Checks two values to determine if they are not equal
  * Accepts:
    * Any two values either side which are of the same type
    * An integer and a double on either side (order not significant)
  * Returns:
    * `true` if both provided values are not exactly the same.&#x20;
    * `false` otherwise.
  * Precedence: 2
* `>`: Checks two numbers to determine which is greater
  * Accepts:
    * Any two numbers (int or double) either side
  * Returns:
    * `true` if the number provided on the left is greater than the number provided on the right.
    * `false` otherwise.
  * Precedence: 2
* `<`: Checks two numbers to determine which is lesser
  * Accepts:
    * Any two numbers (int or double) either side
  * Returns:
    * `true` if the number provided on the left is lesser than the number provided on the right.
    * `false` otherwise.
  * Precedence: 2
* `>=`: Checks two numbers to determine which is greater, or whether both are equal
  * Accepts:
    * Any two numbers (int or double) either side
  * Returns:
    * `true` if the number provided on the left is greater than the number provided on the right, or if both numbers are equal.
    * `false` otherwise.
  * Precedence: 2
* `<=`: Checks two numbers to determine which is lesser, or whether both are equal
  * Accepts:
    * Any two numbers (int or double) either side
  * Returns:
    * `true` if the number provided on the left is lesser than the number provided on the right, or if both numbers are equal.
    * `false` otherwise.
  * Precedence: 2

## Variables

Variables are defined and modified with the syntax:

```
name = value
```

where:

* `name` is an identifier, and
* `value` is a literal, expression, or identifier previously assigned to a variable.

All variables must have a known type and value at definition time. When updating a variable, the type may not change.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sols.dev/syntax.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
